Skip to content

pem: fix to exactly match the legacy PEM crypt annotation header - #2440

Closed
vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:pemparse
Closed

vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:pemparse

Conversation

@vszakats

@vszakats vszakats commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Before this patch it matched if the header had extra characters appended
to it.

Reported by Copilot
#2438 (comment)
Follow-up to 386e012

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 PEM encrypted-key detection so the “Proc-Type: 4,ENCRYPTED” annotation is only recognized when it matches the legacy header exactly, preventing false positives when extra characters are appended.

Changes:

  • Updates the encrypted PEM header detection logic in ssh2_pem_parse() to enforce an exact legacy header match.

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

Comment thread src/pem.c Resolved
This reverts commit cf71ff2.

Nope. Fails for short strings. Such a staggeringly bad story in C for
doing a simple string comparison. Each memcmp, strcmp, strncmp is a
footgun and impossible to figure out if they do what they should without
expecting context, and also impossible to figure out what the intent may
have been. Just bad.

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.

@vszakats vszakats closed this in e3a428b Jul 28, 2026
@vszakats
vszakats deleted the pemparse branch July 28, 2026 11:18
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