Repository navigation
Conversation
Follow-up to a343024 libssh2#2361 Follow-up to 0309229 libssh2#248
There was a problem hiding this comment.
Pull request overview
This PR is a small tidy-up in the OpenSSH private key parsing path, adjusting local buffer typing to avoid a pointer-to-pointer cast when base64-decoding key material in pem_parse_data_openssh().
Changes:
- Change the base64 decode output buffer variable from
unsigned char *tochar *to matchssh2_base64_decode()’schar **API. - Assign the decoded buffer into the
struct string_bufasunsigned char *for subsequent binary parsing without changing parsing behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vszakats
added a commit
that referenced
this pull request
Jul 24, 2026
Also use it from `ssh2_match_string()` to reduce casts. Apparently casting the return pointer of `ssh2_get_string()` buffer is frowned upon, though existing practice and not completelely clear if UB or not. Current practice (with two exceptions, now reduced to one in WinCNG code) is to declare the return buffer as `unsigned char *`, then cast that result everywhere on use. It results in excessive casts. The frowned-upon alternative to avoid this, is to declare as `char *` and pass it to `ssh2_get_string()` as `(unsigned char **)&data`. This new API avoid this, and allows to declare as `char *data`, retrieve it without cast, and use it without casts too. Ref: #2420 Ref: a7d05f9 #2422 Closes #2424
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.
Follow-up to a343024 #2361
Follow-up to 0309229 #248