lib-sasl: Avoid null pointer in empty response check - #310
Open
srkyn wants to merge 1 commit into
Open
Conversation
The SASL request API permits a NULL data pointer when the response size is zero. Skip the NUL scan for that empty-input case so the supported no-initial-response path does not pass NULL to memchr. Signed-off-by: David Sarkisyan <david@srkyn.com>
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.
sasl_server_request_initial()permits a null data pointer when the response size is zero. This is the normal no-initial-response case used by mechanisms such as LOGIN and CRAM-MD5. The NUL check still passed that pointer tomemchr(), which is undefined by the C library contract even with a zero length and is reported by UBSan.Skip the scan when the response is empty. Non-empty response handling is unchanged.
Tests:
b2b2d74e0900e3e3d0ba0392fac9c4cce989aab1test-sasl-authentication: 533 tests passed with Clang UBSan, with the unrelated function-type sanitizer disabledtest-sasl-authentication: 533 tests passed with GCCAUTH LOGIN: normal challenge, no UBSan diagnostic