diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index c79fa8d3..c96a9167 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -299,22 +299,6 @@ CF_Logical_PduBuffer_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *txn, return ph; } -/*---------------------------------------------------------------- - * - * Internal helper routine only, not part of API. - * - *-----------------------------------------------------------------*/ -static inline size_t CF_strnlen(const char *str, size_t maxlen) -{ - const char *end = memchr(str, 0, maxlen); - if (end != NULL) - { - /* actual length of string is difference */ - maxlen = end - str; - } - return maxlen; -} - /*---------------------------------------------------------------- * * Application-scope internal function @@ -344,10 +328,10 @@ CFE_Status_t CF_CFDP_SendMd(CF_Transaction_t *txn) /* at this point, need to append filenames into md packet */ /* this does not actually copy here - that is done during encode */ md->source_filename.length = - CF_strnlen(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename)); + OS_strnlen(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename)); md->source_filename.data_ptr = txn->history->fnames.src_filename; md->dest_filename.length = - CF_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename)); + OS_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename)); md->dest_filename.data_ptr = txn->history->fnames.dst_filename; CF_CFDP_EncodeMd(ph->penc, md); diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index 4b35c9b6..f9068578 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -184,20 +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; } - len = strlen(linebuf); + len = OS_strnlen(linebuf, (CF_FILENAME_MAX_LEN * 2) + 128); ret = CF_WrappedWrite(fd, linebuf, len); if (ret != len) { diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index bf36813b..18e86141 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -41,7 +41,7 @@ void UT_DefaultHandler_CF_WriteTxnQueueDataToFile(void *, UT_EntryKey_t, const U * Generated stub function for CF_FindTransactionBySequenceNumber() * ---------------------------------------------------- */ -CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *chan, +CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t * chan, CF_TransactionSeq_t transaction_sequence_number, CF_EntityId_t src_eid) {