fix: guard against NULL return from CFE_ES_LocateTaskRecordByID in StartAppTask#2759
Open
stark256-spec wants to merge 1 commit into
Open
fix: guard against NULL return from CFE_ES_LocateTaskRecordByID in StartAppTask#2759stark256-spec wants to merge 1 commit into
stark256-spec wants to merge 1 commit into
Conversation
…artAppTask CFE_ES_LocateTaskRecordByID can return NULL if the resource ID is out of range. In CFE_ES_StartAppTask, the return value was used without a null check, causing a potential null pointer dereference at the subsequent CFE_ES_TaskRecordIsUsed() call and memset(). Add a null check matching the pattern used in CFE_ES_AppCreate: if no slot is available, delete the newly created OS task to avoid leaking the OSAL resource, log the error, and return CFE_ES_NO_RESOURCE_IDS_AVAILABLE. Fixes nasa#2491
Author
|
Checking in on this one — static analysis flagged a real NULL-deref path here and the fix is small and self-contained. If there's a preferred reviewer for ES-module changes, happy to tag them directly. Let me know if anything needs adjusting before this goes to CCB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2491
Problem
In
CFE_ES_StartAppTask, the return value ofCFE_ES_LocateTaskRecordByIDwas used without a null check. The function can return NULL when the resource ID is out of range, leading to a null pointer dereference at the subsequentCFE_ES_TaskRecordIsUsed()call andmemset(). This was flagged by Klocwork static analysis.Fix
Add a null check immediately after
CFE_ES_LocateTaskRecordByID, following the same pattern used inCFE_ES_AppCreate(whereLocateAppRecordByIDis already guarded):TaskRecPtr == NULL: log the error, callOS_TaskDeleteon the newly created OSAL task to avoid leaking the OS resource, setCFE_ES_NO_RESOURCE_IDS_AVAILABLE, and return.Test plan