Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes an out-of-memory (OOM) crash in libssh2_userauth_publickey_sk() by adding allocation failure checks before using session->userauth_pblc_method.
Changes:
- Added NULL checks after
SSH2_ALLOC()for ECDSA SK key method selection. - Added NULL checks after
SSH2_ALLOC()for ED25519 SK key method selection.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reported by GitHub Code Quality Follow-up to ed439a2 libssh2#698
Comment on lines
2321
to
+2327
| session->userauth_pblc_method_len = strlen(ecdsa); | ||
| session->userauth_pblc_method = | ||
| SSH2_ALLOC(session, session->userauth_pblc_method_len); | ||
| if(!session->userauth_pblc_method) | ||
| return ssh2_err(session, LIBSSH2_ERROR_ALLOC, | ||
| "Unable to allocate memory " | ||
| "for public key method ECDSA"); |
Member
Author
There was a problem hiding this comment.
Most of this source follows the bad pattern prior to this patch.
vszakats
added a commit
that referenced
this pull request
Jul 18, 2026
…y fixes Make sure to store buffer lengths to the session structure only after the buffer allocation was successful. To avoid leaving non-zero length there on error cases. Also: - fix to fail username/password bounds check with `LIBSSH2_ERROR_OUT_OF_BOUNDARY` instead of conflating it with `LIBSSH2_ERROR_ALLOC` in `userauth_keyboard_interactive()`, and `userauth_password()`. - fix to verify method sizes before calling `strncmp()` in `libssh2_userauth_publickey_sk()` Follow-up to ed439a2 #698 - replace `strlen()` calls with `sizeof()` for efficiency in `libssh2_userauth_publickey_sk()` Follow-up to ed439a2 #698 - fix error message text in `userauth_keyboard_interactive()`. Reported by Copilot. Bug: #2224 (comment) - bail out on zero-length public key in `ssh2_userauth_publickey()`, to avoid zero-length allocation and imporove reported error. Reported by Copilot. Bug: #2224 (comment) Bug: #2220 (comment) Closes #2224
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.
Also free the buffers if set before allocating.
Reported by GitHub Code Quality and Copilot
Follow-up to ed439a2 #698