Skip to content

libssh2: make the knownhost name check also verify length - #23423

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/test3990
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/test3990

Conversation

@bagder

@bagder bagder commented Oct 15, 2026

Copy link
Copy Markdown
Member

To avoid it prefix-matching

Verified by test 3990 and 3991, provided by Samuel.

Reported-by: Samuel Henrique

@github-actions github-actions Bot added the tests label Oct 15, 2026
@bagder
bagder marked this pull request as ready for review October 15, 2026 22:03
@bagder
bagder requested a balanced review from Copilot October 15, 2026 22:03

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.

🟢 Approval recommended

The focused length check and supporting regression tests have no identified blocking issues.

0 open findings

What changed in this PR

This PR prevents libssh2 known-host selection from accepting hostname prefixes by requiring equal lengths before comparison.

Changes:

  • Require exact hostname matching for bracketed host-and-port entries.
  • Add and register regression tests for prefix and unrelated-host entries.
File Description
tests/​test3990.pl Generate known-host fixtures with distinct key types.
tests/​Makefile.am Include the new fixture script.
tests/​data/​test3991 Test an unrelated host appearing first.
tests/​data/​test3990 Test a hostname prefix appearing first.
tests/​data/​Makefile.am Register both regression tests.
lib/​vssh/​libssh2.c Check hostname length before comparison.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

To avoid it prefix-matching

Verified by test 3990 and 3991, provided by Samuel.

Reported-by: Samuel Henrique
@bagder bagder closed this in a978dfa Oct 16, 2026
@bagder
bagder deleted the bagder/test3990 branch October 16, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants