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 variable possible in EVS_SendViaPorts #2334

Closed
markhermeling opened this issue May 12, 2023 · 0 comments · Fixed by #2401
Closed

Uninitialized variable possible in EVS_SendViaPorts #2334

markhermeling opened this issue May 12, 2023 · 0 comments · Fixed by #2401
Assignees

Comments

@markhermeling
Copy link

https://github.com/nasa/cFE/blob/e3b67674630cd098dbdefdc4e727c04a2b23dc31/modules/evs/fsw/src/cfe_evs_utils.c#LL545C3-L545C3

There is a possibility of an uninitialized variable in EVS_SendViaPorts in cue_evs_utils.c. I do not have a running example, problem found using static analysis with GrammaTech CodeSonar, screenshot attached.
Screenshot 2023-05-12 at 2 39 43 PM

Line 545 calls CFE_MSG_GetMsgTime(CFE_MSG_PTR(EVS_PktPtr->TelemetryHeader), &PktTime);
this function is in cue_msg_sechdr_time.c
however, if either the first, or the second parameter is NULL, then that function will return CFE_MSG_BAD_ARGUMENT on line 81 of that file. Second parameter is unlikely to be NULL as it is a pointer to a local variable from EVS_SendViaPorts().

Which means it does not initialize PktTime, which is subsequently used in the CFE_TIME_Print call.

This may not be a problem if the compiler initializes local variables to 0, but there is no guarantee on that.

PktTime is used in a time calculation to convert epoch to calendar time, so worst case this could take a long time, and/or print garbage.

Probably would be better to check the return of the call to CFE_MSG_GetMsgTime and set PktTime to 0 if CFE_MSG_BAD_ARGUMENT is returned.

@skliper skliper self-assigned this Jul 17, 2023
dzbaker added a commit that referenced this issue Sep 1, 2023
Fix #2334, Uninitialized PktTime in EVS_SendViaPorts
@dzbaker dzbaker closed this as completed in 5843440 Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants