Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Uninitialized string copy if move location is empty #48

@skliper

Description

@skliper

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
Pathname is only set when move is not empty, but the copy is done outside that condition:

DS/fsw/src/ds_file.c

Lines 891 to 906 in 733b2b2

char PathName[DS_TOTAL_FNAME_BUFSIZE];
/*
** First, close the file...
*/
OS_close(FileStatus->FileHandle);
/*
** Move file only if table has a downlink directory name...
*/
if (DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] != '\0')
{
/*
** Make sure directory name does not end with slash character...
*/
strcpy(PathName, DS_AppData.DestFileTblPtr->File[FileIndex].Movename);

strncpy(FileStatus->FileName, PathName, sizeof(PathName));

To Reproduce
Produce the packet with move empty

Expected behavior
Only copy over if Pathname was set

System observed on:
Observed, also flagged by static analysis

Additional context
Introduced with file complete tlm packet updates - #39, so doesn't impact draco-rc2

Reporter Info
Jacob Hageman - NASA/GSFC

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions