Skip to content

Commit

Permalink
Fix #1195, Avoid implicit conversion from vsnprintf errors
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Mar 17, 2021
1 parent 7f8e475 commit d40245c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/evs/fsw/src/cfe_evs_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,11 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1
ExpandedLength =
vsnprintf((char *)LongEventTlm.Payload.Message, sizeof(LongEventTlm.Payload.Message), MsgSpec, ArgPtr);

/* Were any characters truncated in the buffer? */
if (ExpandedLength >= sizeof(LongEventTlm.Payload.Message))
/*
* If vsnprintf is bigger than message size, mark with truncation character
* Note negative returns (error from vsnprintf) will just leave the message as-is
*/
if (ExpandedLength >= (int)sizeof(LongEventTlm.Payload.Message))
{
/* Mark character before zero terminator to indicate truncation */
LongEventTlm.Payload.Message[sizeof(LongEventTlm.Payload.Message) - 2] = CFE_EVS_MSG_TRUNCATED;
Expand Down

0 comments on commit d40245c

Please sign in to comment.