Skip to content

tidy-up: C nits - #2308

Closed
vszakats wants to merge 7 commits into
libssh2:masterfrom
vszakats:tidycode
Closed

vszakats wants to merge 7 commits into
libssh2:masterfrom
vszakats:tidycode

Conversation

@vszakats

@vszakats vszakats commented Jul 14, 2026 •

Copy link
Copy Markdown
Member
  • crypto, openssl: sync passphrase type with rest of code in
    ssh2_ed25519_new_private().
  • hostkey: merge if()s in hostkey_method_ssh_rsa_init().
  • hostkey: merge if()s in hostkey_method_ssh_dss_init().
  • knownhost: sizeof() the target variable, not its manually resolved type.
    For robustness.
  • knownhost: replace repeate LENGTH references with sizeof().
  • openssl: move two assigns later in ssh2_mlkem_new().
    To keep the alloc/check pattern intact and avoid unnecessary
    assignments on OOM.
  • userauth: do not check unsigned value for negative in
    libssh2_sign_sk().
  • openssl: sync flags type with sibling function in
    ossl_ecdsa_sk_openssh_priv_to_pubkey().

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 applies a set of small “tidy-up” changes across crypto/OpenSSL, hostkey parsing, known-host handling, and SK userauth to improve type consistency and reduce minor nits/warnings while preserving behavior.

Changes:

  • Align passphrase/flags parameter types with adjacent code paths (ED25519 private key loading; ECDSA-SK key extraction).
  • Simplify control flow by merging sequential error checks in RSA/DSS hostkey initializers.
  • Improve robustness/readability by using sizeof(*ptr) / sizeof(array) patterns and avoiding pointless signed comparisons on unsigned values.

Reviewed changes

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

Show a summary per file
File Description
src/userauth.c Removes a meaningless “negative” check on an unsigned handle_len by switching to a zero-check.
src/openssl.c Syncs parameter types for consistency; keeps ML-KEM alloc/check pattern intact by moving length assignments after OOM checks.
src/knownhost.c Replaces manually repeated sizes/types with sizeof(*entry) and sizeof(hash) for robustness.
src/hostkey.c Merges multiple sequential parse-validation if blocks into single short-circuit checks without changing semantics.
src/HACKING-CRYPTO.md Updates documented prototype to match the code/header signature.
src/crypto.h Updates ssh2_ed25519_new_private() prototype to match the OpenSSL implementation and surrounding conventions.

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

@vszakats vszakats changed the title tidy-up: code nits tidy-up: C nits Jul 14, 2026
@vszakats vszakats closed this in 1164743 Jul 14, 2026
@vszakats
vszakats deleted the tidycode branch July 14, 2026 11:41
vszakats added a commit that referenced this pull request Jul 28, 2026
- `ssh2_mlkem_new()` with `ssh2_curve25519_new()`.
- also inline two comments.

Follow-up to 1164743 #2308
Follow-up to 41389f8 #2029
Follow-up to 3ba252e #1644

Closes #2442
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