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

CFE_SB_MsgHdrSize returns size_t but still attempts to return CFE status code #1667

Closed
jphickey opened this issue Jul 15, 2021 · 1 comment · Fixed by #1665
Closed

CFE_SB_MsgHdrSize returns size_t but still attempts to return CFE status code #1667

jphickey opened this issue Jul 15, 2021 · 1 comment · Fixed by #1665
Labels
Milestone

Comments

@jphickey
Copy link
Contributor

Describe the bug
The CFE_SB_MsgHdrSize() function returns a size_t value. Therefore, there is no provision/possibility for an error to be returned.

However, if passed a NULL argument, this still attempts to return CFE_SB_BAD_ARGUMENT which will be implicitly converted to a size_t value - which is platform-defined. Notably, since size_t is unsigned, the result is always positive (success range) and will not be correctly interpreted by the caller.

To Reproduce
Call CFE_SB_MsgHdrSize() with a NULL MsgPtr argument.

Expected behavior
This function should probably return 0 instead of CFE_SB_BAD_ARGUMENT in this case.
Cannot return CFE status codes from a function that does not return CFE_Status_t (or int32).

Code snips

if (MsgPtr == NULL)
{
return CFE_SB_BAD_ARGUMENT;
}

System observed on:
Ubuntu

Additional context
This line was also not being covered by the coverage test (#471) and the return type mismatch prevents this from being covered properly.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey added the bug label Jul 15, 2021
@jphickey
Copy link
Contributor Author

This also affects CFE_SB_GetUserDataLength()

astrogeco pushed a commit that referenced this issue Jul 20, 2021
* Fix #1667, CFE_SB_MsgHdrSize returns size_t but still attempts to return CFE status code
paulober pushed a commit to paulober/cFE that referenced this issue Aug 1, 2021
* Fix nasa#1667, CFE_SB_MsgHdrSize returns size_t but still attempts to return CFE status code
@skliper skliper added this to the 7.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants