wolfssl_local_MatchBaseName: fix 1-byte read out of bounds looking for "@" - #11237
Open
holtrop-wolfssl wants to merge 1 commit into
Open
wolfssl_local_MatchBaseName: fix 1-byte read out of bounds looking for "@"#11237holtrop-wolfssl wants to merge 1 commit into
holtrop-wolfssl wants to merge 1 commit into
Conversation
…r "@" Fixes F-7106
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a 1-byte out-of-bounds read in wolfssl_local_MatchBaseName() when scanning an RFC822 (email) constraint base string for '@', ensuring the length bound is checked before dereferencing the pointer. This fits into wolfCrypt’s ASN.1 / certificate name-constraints handling, improving memory safety in certificate validation paths.
Changes:
- Reordered the loop condition in
wolfssl_local_MatchBaseName()to prevent dereferencingbase[baseSz]when the base contains no'@'. - Added a regression test that copies the base into a heap buffer of exactly
baseSzbytes (no NUL terminator) to make the prior over-read detectable under ASAN/valgrind.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wolfcrypt/src/asn.c | Fixes the RFC822 base scan loop to check bounds before dereference, preventing a 1-byte OOB read. |
| tests/api/test_asn.c | Adds a regression test using a non-NUL-terminated heap buffer to detect the historical over-read with sanitizers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
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.
Description
wolfssl_local_MatchBaseName: fix 1-byte read out of bounds looking for "@"
Fixes F-7106
Testing
How did you test?
Checklist