Skip to content

Commit

Permalink
Fix #117, 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 10, 2024
1 parent f033752 commit 50808eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fsw/src/fm_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ void FM_ChildFileInfoCmd(FM_ChildQueueEntry_t *CmdArgs)

/* Report directory or filename state, name, size and time */
ReportPtr->FileStatus = (uint8)CmdArgs->FileInfoState;
/* SAD: The Filename is null terminated and sized appropriately. This strncpy of Filename is ok */
strncpy(ReportPtr->Filename, CmdArgs->Source1, OS_MAX_PATH_LEN - 1);
ReportPtr->Filename[OS_MAX_PATH_LEN - 1] = '\0';

Expand Down Expand Up @@ -1157,6 +1158,7 @@ void FM_ChildDirListPktCmd(const FM_ChildQueueEntry_t *CmdArgs)

ReportPtr = &FM_GlobalData.DirListPkt.Payload;

/* SAD: The DirName is null terminated and sized appropriately. This strncpy of DirName is ok */
strncpy(ReportPtr->DirName, CmdArgs->Source1, OS_MAX_PATH_LEN - 1);
ReportPtr->DirName[OS_MAX_PATH_LEN - 1] = '\0';
ReportPtr->FirstFile = CmdArgs->DirListOffset;
Expand Down Expand Up @@ -1193,6 +1195,7 @@ void FM_ChildDirListPktCmd(const FM_ChildQueueEntry_t *CmdArgs)
if ((PathLength + EntryLength) < sizeof(LogicalName))
{
/* Add filename to directory listing telemetry packet */
/* SAD: The EntryName is null terminated and sized appropriately. This strncpy of EntryName is ok */
strncpy(ListEntry->EntryName, OS_DIRENTRY_NAME(DirEntry), sizeof(ListEntry->EntryName) - 1);
ListEntry->EntryName[sizeof(ListEntry->EntryName) - 1] = '\0';

Expand Down
2 changes: 2 additions & 0 deletions fsw/src/fm_cmd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ CFE_Status_t FM_GetDirectorySpaceEstimate(const char *Directory, uint64 *BlockCo
TotalBytes = 0;

memset(&DirEntry, 0, sizeof(DirEntry));
/* SAD: The FullPath is null terminated and sized appropriately. This strncpy and strlen of FullPath is ok */
strncpy(FullPath, Directory, sizeof(FullPath) - 1);
FullPath[sizeof(FullPath) - 1] = 0;
DirLen = strlen(FullPath);
Expand Down Expand Up @@ -607,6 +608,7 @@ CFE_Status_t FM_GetDirectorySpaceEstimate(const char *Directory, uint64 *BlockCo
/* Read each directory entry and stat the files */
while (OS_DirectoryRead(DirId, &DirEntry) == OS_SUCCESS)
{
/* SAD: The FullPath is null terminated and sized appropriately. This strncpy of FullPath is ok */
strncpy(&FullPath[DirLen], OS_DIRENTRY_NAME(DirEntry), sizeof(FullPath) - DirLen - 1);

OS_Status = OS_stat(FullPath, &FileStat);
Expand Down
2 changes: 2 additions & 0 deletions fsw/src/fm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ bool FM_DecompressFileCmd(const CFE_SB_Buffer_t *BufPtr)

/* Set handshake queue command args */
CmdArgs->CommandCode = FM_DECOMPRESS_FILE_CC;
/* SAD: The Source1 is null terminated and sized appropriately. This strncpy of Source1 is ok */
strncpy(CmdArgs->Source1, CmdPtr->Source, OS_MAX_PATH_LEN - 1);
CmdArgs->Source1[OS_MAX_PATH_LEN - 1] = '\0';
/* SAD: The Target is null terminated and sized appropriately. This strncpy of Target is ok */
strncpy(CmdArgs->Target, CmdPtr->Target, OS_MAX_PATH_LEN - 1);
CmdArgs->Target[OS_MAX_PATH_LEN - 1] = '\0';

Expand Down

0 comments on commit 50808eb

Please sign in to comment.