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

FM_ChildSizeTimeMode doesn't clear FileMode on OS_stat failure #43

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

FM_ChildSizeTimeMode doesn't clear FileMode on OS_stat failure #43

skliper opened this issue Aug 1, 2022 · 0 comments · Fixed by #45
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Aug 1, 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
FileMode could be uninitilized when written if there's an OS_stat failure since it's not cleared:

FM/fsw/src/fm_child.c

Lines 1587 to 1610 in 9210c2d

int32 FM_ChildSizeTimeMode(const char *Filename, uint32 *FileSize, uint32 *FileTime, uint32 *FileMode)
{
int32 Result = OS_SUCCESS;
os_fstat_t FileStatus;
memset(&FileStatus, 0, sizeof(FileStatus));
Result = OS_stat(Filename, &FileStatus);
if (Result != OS_SUCCESS)
{
*FileSize = 0;
*FileTime = 0;
}
else
{
*FileTime = OS_FILESTAT_TIME(FileStatus);
*FileSize = OS_FILESTAT_SIZE(FileStatus);
*FileMode = OS_FILESTAT_MODE(FileStatus);
}
return (Result);
} /* End of FM_ChildSizeTimeMode */

To Reproduce
Pass in uninitialized FileMode, observe not cleared on OS_stat failure.

Expected behavior
Should clear all values.

System observed on:
Observation

Additional context
Low likelihood of ever seeing this (maybe file deleted between directory read and OS_stat?), and just would write uninitialized data to the output.

Reporter Info
Jacob Hageman - NASA/GSFC

@skliper skliper added the bug label Aug 1, 2022
@skliper skliper added this to the Draco milestone Aug 1, 2022
@skliper skliper self-assigned this Aug 1, 2022
@dzbaker dzbaker closed this as completed in 952de35 Aug 3, 2022
dzbaker added a commit that referenced this issue Aug 3, 2022
Fix #34 #37 #43 #44, UT cleanup, remove unreachable code, initialize FileMode on OS_stat failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants