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

Fix #1237, avoid calling memchr() with unknown size buffer #1238

Merged
merged 1 commit into from
Mar 25, 2022

Conversation

jphickey
Copy link
Contributor

Describe the contribution
In some systems, passing a large size value to memchr() causes it to return NULL, even if the char is guaranteed to be found within the actual valid buffer memory.

This modifies the string buffer comparison function to actively check for this sentinel value and use "strlen()" instead.

Fixes #1237

Testing performed
Build and sanity check, run all tests on both Ubuntu (latest version) and CentOS 7 VM

Expected behavior changes
Tests pass in both systems (no SEGV on CentOS 7)

System(s) tested on
Ubuntu 21.10
CentOS 7

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

In some systems, passing a large size value to memchr() causes it to
return NULL, even if the char is guaranteed to be found within the
actual valid buffer memory.

This modifies the string buffer comparison function to actively
check for this sentinel value and use "strlen()" instead.
@skliper skliper added the unit-test Tickets related to the OSAL unit testing (functional and/or coverage) label Mar 25, 2022
@skliper skliper added this to the Draco milestone Mar 25, 2022
@jphickey jphickey added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Mar 25, 2022
@jphickey
Copy link
Contributor Author

Note - format check issue appears to be a problem that was already in the build (not caused by this PR)

astrogeco added a commit to nasa/cFS that referenced this pull request Mar 25, 2022
Co-authored-by: Joseph Hickey <jphickey@users.noreply.github.com>
astrogeco added a commit to nasa/cFS that referenced this pull request Mar 25, 2022
Co-authored-by: Joseph Hickey <jphickey@users.noreply.github.com>
@astrogeco astrogeco merged commit 571e952 into nasa:main Mar 25, 2022
@dmknutsen
Copy link
Contributor

Approved

@dmknutsen dmknutsen added the CCB:Approved Indicates code review and approval by community CCB label Mar 30, 2022
@astrogeco astrogeco removed the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Apr 6, 2022
@jphickey jphickey deleted the fix-1237-stringbuf-check branch October 10, 2022 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB draco-rc1 unit-test Tickets related to the OSAL unit testing (functional and/or coverage)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UtAssert_StringBufCompare SEGV when -1 for size passed in (on CentOS 7)
4 participants