From 10747de66f82de7a7fc17de5dca1be910073ed99 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 17 Mar 2021 11:23:19 -0400 Subject: [PATCH] Fix #1195, Avoid implicit conversion from vsnprintf errors --- modules/evs/fsw/src/cfe_evs_utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/evs/fsw/src/cfe_evs_utils.c b/modules/evs/fsw/src/cfe_evs_utils.c index de93e565f..b59350851 100644 --- a/modules/evs/fsw/src/cfe_evs_utils.c +++ b/modules/evs/fsw/src/cfe_evs_utils.c @@ -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;