From b532de9ca10e46632cebf7b056fb7a5834d9bb6a Mon Sep 17 00:00:00 2001 From: jdfiguer Date: Thu, 6 Jun 2024 16:06:05 -0400 Subject: [PATCH] Fix #444, Adds JSC 2.1 Static Analysis comments --- fsw/src/cf_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index 4b35c9b6..e637ee14 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -184,19 +184,23 @@ CFE_Status_t CF_WriteHistoryEntryToFile(osal_id_t fd, const CF_History_t *histor { case 0: CF_Assert(history->dir < CF_Direction_NUM); + /* SAD: No need to check snprintf return; buffer size is sufficient for the formatted output */ snprintf(linebuf, sizeof(linebuf), "SEQ (%lu, %lu)\tDIR: %s\tPEER %lu\tSTAT: %d\t", (unsigned long)history->src_eid, (unsigned long)history->seq_num, CF_DSTR[history->dir], (unsigned long)history->peer_eid, (int)history->txn_stat); break; case 1: + /* SAD: No need to check snprintf return; buffer size is sufficient for the formatted output */ snprintf(linebuf, sizeof(linebuf), "SRC: %s\t", history->fnames.src_filename); break; case 2: default: + /* SAD: No need to check snprintf return; buffer size is sufficient for the formatted output */ snprintf(linebuf, sizeof(linebuf), "DST: %s\n", history->fnames.dst_filename); break; } + /* SAD: Using strlen since linebuf is guaranteed to be null-terminated by snprintf */ len = strlen(linebuf); ret = CF_WrappedWrite(fd, linebuf, len); if (ret != len)