nasa / cFE

The Core Flight System (cFS) Core Flight Executive (cFE)
Apache License 2.0
410 stars 202 forks source link

Possible NULL ptr deference in CFE_ES_StartAppTask #2491

Open ejtimmon opened 9 months ago

ejtimmon commented 9 months ago

Describe the bug Static code analysis finding from the Klocwork tool. Line numbers based on the draco-rc4 tag. On line 606 in the cfe_es_apps.c file, the function CFE_ES_LocateTaskRecordByID could return a value of NULL. This will then set TaskRecPtr to NULL. Then on line 607 TaskRecPtr will be dereferenced.

To Reproduce Run Klocwork SCA analysis

Reporter Info Beth Geist/NASA GSFC

jphickey commented 9 months ago

This is a false positive. I think it was "detected" by tools in the past, hence the comment here:

https://github.com/nasa/cFE/blob/7f5ebcd15032fe31e7ef0e5ff4ef624d51d66e16/modules/es/fsw/src/cfe_es_apps.c#L600-L605

Basically - the CFE_ES_TaskId_FromOSAL() call can never fail, it always produces a valid ID, and thus CFE_ES_LocateTaskRecordByID() always returns non-NULL in this context. If we added an "if" to check for it, it would end up being unreachable code.