Repository navigation
Conversation
- fix off by one error when loading public keys with no id. - make sure that sp_len is positive and avoid overflows. These were fixed in `userauth_read_file_pubkey()` earlier, but missed from the same code loading pubkeys from memory buffers. Follow-up to 4820556 libssh2#386 Follow-up to 3e47ca8
userauth_read_blob_pubkey()userauth_read_blob_pubkey()
There was a problem hiding this comment.
Pull request overview
This PR brings the in-memory public key parsing path (userauth_read_blob_pubkey()) in line with the previously-fixed file-based path (userauth_read_file_pubkey()), addressing an out-of-bounds/underflow risk when searching for the optional id/comment field and tightening length arithmetic to avoid overflow/underflow cases.
Changes:
- Compute a bounded
sp_lenbefore subtracting frompubkey_lento avoid potential unsigned underflow in thememchr()scan length. - Align local variable declarations between the blob and file pubkey parsing functions for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
These were fixed in
userauth_read_file_pubkey()earlier, but missedfrom the sibling code loading pubkey from memory buffer (as opposed to
file). Sibling code made it into the codebase after the first fix, but
it was based code copy-pasted from a pre-fix revision.
Bug: #2354 (comment)
Follow-up to 4820556 #386
Follow-up to 18cfec8
Follow-up to 3e47ca8