Skip to content

Commit

Permalink
Fix #93, Adds JSC 2.1 static analysis comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfiguer authored and jdfiguer committed Jun 6, 2024
1 parent 69fc1b9 commit 7b94737
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fsw/src/cs_compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,19 +536,23 @@ void CS_RecomputeEepromMemoryChildTask(void)

if (Table == CS_EEPROM_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "EEPROM", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_MEMORY_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Memory", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_CFECORE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "cFE Core", CS_TABLETYPE_NAME_SIZE);
CS_AppData.HkPacket.Payload.CfeCoreBaseline = NewChecksumValue;
}
if (Table == CS_OSCORE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "OS", CS_TABLETYPE_NAME_SIZE);
CS_AppData.HkPacket.Payload.OSBaseline = NewChecksumValue;
}
Expand Down
1 change: 1 addition & 0 deletions fsw/src/cs_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CFE_Status_t CS_SbInit(void)
CFE_Status_t Result = CFE_SUCCESS;

/* Initialize app configuration data */
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(CS_AppData.PipeName, CS_CMD_PIPE_NAME, CS_CMD_PIPE_NAME_LEN);

CS_AppData.PipeDepth = CS_PIPE_DEPTH;
Expand Down
15 changes: 15 additions & 0 deletions fsw/src/cs_table_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ CFE_Status_t CS_ValidateTablesChecksumDefinitionTable(void *TblPtr)
StateField = OuterEntry->State;

/* Check for non-zero length for table name */
/* SAD: Using strlen since OuterEntry->Name is null-terminated in cs/fsw/src/cs_table_processing.c::CS_ProcessNewAppDefinitionTable() */
if (strlen(OuterEntry->Name) != 0)
{
/* Verify valid state definition */
Expand Down Expand Up @@ -357,6 +358,7 @@ CFE_Status_t CS_ValidateAppChecksumDefinitionTable(void *TblPtr)
}
BadCount++;
}
/* SAD: Using strlen since OuterEntry->Name is null-terminated in cs/fsw/src/cs_table_processing.c::CS_ProcessNewAppDefinitionTable() */
else if (strlen(OuterEntry->Name) != 0)
{
/* Verify valid state definition */
Expand Down Expand Up @@ -466,6 +468,7 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En
memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable));
memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable));

/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(&TableType[0], "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init the table type string */

/* We don't want to be doing chekcksums while changing the table out */
Expand Down Expand Up @@ -528,10 +531,12 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En
{
if (Table == CS_EEPROM_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(&TableType[0], "EEPROM", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_MEMORY_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(&TableType[0], "Memory", CS_TABLETYPE_NAME_SIZE);
}

Expand Down Expand Up @@ -825,6 +830,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
osal_id_t Fd = OS_OBJECT_ID_UNDEFINED;
char TableType[CS_TABLETYPE_NAME_SIZE];

/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */

SizeOfTable = NumEntries * SizeofResultsTableEntry;
Expand Down Expand Up @@ -904,18 +910,22 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
{
if (Table == CS_EEPROM_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "EEPROM", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_MEMORY_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Memory", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_TABLES_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Tables", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_APP_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Apps", CS_TABLETYPE_NAME_SIZE);
}

Expand Down Expand Up @@ -967,6 +977,7 @@ CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, C
int32 Loop = 0;
char TableType[CS_TABLETYPE_NAME_SIZE];

/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */

/* Below, there are several values that are returned and assigned, but never evaluated. */
Expand Down Expand Up @@ -1031,18 +1042,22 @@ CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, C
{
if (Table == CS_EEPROM_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "EEPROM", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_MEMORY_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Memory", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_TABLES_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "Table", CS_TABLETYPE_NAME_SIZE);
}
if (Table == CS_APP_TABLE)
{
/* SAD: Using strncpy since the literal is shorter than buffer size, ensuring null-termination */
strncpy(TableType, "App", CS_TABLETYPE_NAME_SIZE);
}

Expand Down

0 comments on commit 7b94737

Please sign in to comment.