Repository navigation
src: misc tidy-ups - #1877
src: misc tidy-ups#1877vszakats wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR performs small cleanups across packet handling, user authentication, and WinCNG code paths to improve consistency and reduce redundant code.
Changes:
- Replace
ALLOC + memsetwithCALLOCfor channel allocation in packet auth-agent open. - Fix/standardize several error messages and correct a comment typo.
- Remove redundant unused-variable silencers and tighten variable scope in
_libssh2_key_sign_algorithm().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/packet.c | Improves allocation/zeroing pattern, updates an error message, and fixes a comment typo. |
| src/userauth.c | Standardizes an allocation error message and scopes version-parsing variables more tightly. |
| src/wincng.c | Removes redundant (void) unused-variable silencers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const char *remote_ver = remote_ver_start + strlen(remote_ver_pre); | ||
| int SSH_BUG_SIGTYPE = is_version_less_than_78(remote_ver); | ||
| if(SSH_BUG_SIGTYPE && *key_method_len == method_len && | ||
| memcmp(key_method, method, method_len)) { |
There was a problem hiding this comment.
memcmp is comparing key_method (type unsigned char **, e.g. &session->userauth_pblc_method) against the method string, so it reads bytes from the session struct rather than the method buffer. This makes the OpenSSH<=7.7 cert handling effectively incorrect/fragile. Compare *key_method to method instead, and adjust the condition to match the intent in the comment (i.e., trigger when the key method actually is the cert method).
| memcmp(key_method, method, method_len)) { | |
| memcmp(*key_method, method, method_len) == 0) { |
| memcmp(key_method, | ||
| "[email protected]", *key_method_len)) { | ||
| if(*key_method_len == method_len && | ||
| memcmp(key_method, method, method_len)) { |
There was a problem hiding this comment.
Same issue as above: memcmp(key_method, method, method_len) compares the pointer-to-pointer rather than the method buffer. It should compare *key_method to method; once fixed, ensure the branch condition matches the intended behavior (append the cert suffix only when the original key method is the cert variant).
| memcmp(key_method, method, method_len)) { | |
| memcmp(*key_method, method, method_len) == 0) { |
- dedupe constant, and replace magic number with `sizeof()`. - drop useless check for non-NULL `filtered_algs` on exit. - fix leaking `filtered_algs` on an error path. - fix to pass `*key_method` to `memcmp()` (was: `key_method`). - fix to compare `memcmp()` against `0` (was: non-zero). - add missing NULL-check before using `*key_method`. - drop redundant `*key_method` NULL-check after use. - scope variables. - avoid camelcase in variable name. - fix formatting. Ref: #1314 (comment) Ref: #1877 (comment) Ref: #1877 (comment) Follow-up to 3a6ab70 #1314 Closes #1881
similar code nearby.
Pointed out by GitHub Code Quality