cFE icon indicating copy to clipboard operation
cFE copied to clipboard

Possible NULL ptr deference in CFE_ES_StartAppTask

Open ejtimmon opened this issue 2 years ago • 1 comments

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

ejtimmon avatar Jan 05 '24 15:01 ejtimmon

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.

jphickey avatar Jan 05 '24 16:01 jphickey