Skip to content

userauth: various fixes to _libssh2_key_sign_algorithm() - #1881

Closed
vszakats wants to merge 9 commits into
libssh2:masterfrom
vszakats:userauthmess
Closed

vszakats wants to merge 9 commits into
libssh2:masterfrom
vszakats:userauthmess

Conversation

@vszakats

@vszakats vszakats commented Apr 23, 2026 •

Copy link
Copy Markdown
Member
  • 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


FIXME?: The comment and code about SSH_BUG_SIGTYPE seem to be
not in sync with each other.

/cc @Tejaswikandula

- scope variables.
- dedupe constant and replace magic number with `sizeof()`.
- drop useless check for non-NULL `filtered_algs`.
- fix leaking `filtered_algs` on an error path.

Follow-up to 3a6ab70 libssh2#1314

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens and corrects _libssh2_key_sign_algorithm() in src/userauth.c, primarily fixing comparison logic and cleaning up memory handling while keeping the intended OpenSSH compatibility behavior intact.

Changes:

  • Replaced hard-coded lengths with sizeof(...)-1 constants and deduped repeated string literals.
  • Fixed incorrect memcmp() usage (wrong pointer, wrong truthiness check) and added a missing NULL-check before freeing/using *key_method.
  • Fixed an error-path leak of filtered_algs and simplified cleanup on exit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/userauth.c Resolved
Comment thread src/userauth.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats closed this in ba2a7ff Apr 24, 2026
@vszakats
vszakats deleted the userauthmess branch April 24, 2026 07:28
vszakats added a commit that referenced this pull request Apr 25, 2026
- size the `filtered-algs` buffer by the server list rather than the
  supported list, since the output is always a subset of the server list
  byte-for-byte.
  Report-and-patch-by: Kit Knox

- use `strttol()` to extract minor version too.
  Pointed out by GitHub Code Quality.

Also:
- rename a variable.
- simplify an expression.
- inline an `if` block.
- drop redundant parentheses.

Follow-up to ba2a7ff #1881
Follow-up to 3a6ab70 #1314

Closes #1885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants