Repository navigation
Reject UINT32_MAX before size + 1 allocations - #1364
Open
ejohnstown wants to merge 1 commit into
Open
ejohnstown wants to merge 1 commit into
ejohnstown wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the username and SSH public-key size-guard changes.
No open issues 🎉
What changed in this PR
This PR hardens username handling and SSH public-key parsing by rejecting UINT32_MAX before adding space for a null terminator, preventing allocation-size wraparound.
Changes:
- Return
WS_BAD_ARGUMENTforUINT32_MAXsizes inwolfSSH_SetUsernameRaw()andDoSshPubKey(). - Add API regression tests for both rejection paths.
| File | Description |
|---|---|
tests/api.c |
Adds maximum-size rejection tests for usernames and SSH public keys. |
src/ssh.c |
Guards both size + 1 allocations against overflow. |
Review effort: Balanced
DoSshPubKey() and wolfSSH_SetUsernameRaw() allocate a word32 size plus one for a null terminator. Both now return WS_BAD_ARGUMENT for a size of UINT32_MAX, where that sum wraps to a zero-byte allocation. - api.c: SetUsernameRaw and ReadKey_buffer reject UINT32_MAX Issue: F-15662, F-15663
ejohnstown
force-pushed
the
size-plus-one-allocs
branch
from
November 2, 2026 20:09
bba0e8a to
3b1504b
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1364
Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
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.
DoSshPubKey() and wolfSSH_SetUsernameRaw() return WS_BAD_ARGUMENT for
a size of UINT32_MAX, where size + 1 wraps to a zero-byte allocation.
Issue: F-15662, F-15663