Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized string copy if move location is empty #48

Closed
2 tasks done
skliper opened this issue Aug 18, 2022 · 0 comments · Fixed by #47
Closed
2 tasks done

Uninitialized string copy if move location is empty #48

skliper opened this issue Aug 18, 2022 · 0 comments · Fixed by #47
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Aug 18, 2022

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

@skliper skliper added the bug label Aug 18, 2022
@skliper skliper added this to the Draco milestone Aug 18, 2022
@skliper skliper self-assigned this Aug 18, 2022
dzbaker added a commit that referenced this issue Aug 25, 2022
Fix #46 #48 #49 #50, Resolve multiple static analysis issues (includes bug fixes) and remove unnecessary UT handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants