Skip to content

Commit

Permalink
Merge pull request #1235 from skliper/fix1195-vsnprintf_error
Browse files Browse the repository at this point in the history
Fix #1195, Avoid implicit conversion from vsnprintf errors
  • Loading branch information
astrogeco authored Mar 18, 2021
2 parents 4b58081 + 10747de commit 68cd788
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 68cd788

Please sign in to comment.