Skip to content

x509asn1: fix operator order in do_pubkey#21533

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

x509asn1: fix operator order in do_pubkey#21533
bagder wants to merge 1 commit into
masterfrom
bagder/x509asn1

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented May 7, 2026

Check the range before reading data, as it would otherwise read one byte too many.

Reported-by: Andrew Nesbit

Check the range before reading data, as it would otherwise read one byte
too many.

Reported-by: Andrew Nesbit
@github-actions github-actions Bot added the TLS label May 7, 2026
@bagder bagder requested a review from Copilot May 7, 2026 21:57
@bagder bagder marked this pull request as ready for review May 7, 2026 21:57
Copy link
Copy Markdown

Copilot AI left a comment

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 fixes a potential out-of-bounds read in the X.509 ASN.1 public key parsing logic by reordering a loop condition so the buffer boundary is checked before dereferencing.

Changes:

  • Reordered the for loop condition in do_pubkey() to ensure q < elem.end is evaluated before !*q, preventing reading past elem.end.

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

@bagder bagder closed this in cda0268 May 8, 2026
@bagder bagder deleted the bagder/x509asn1 branch May 8, 2026 08:27
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Check the range before reading data, as it would otherwise read one byte
too many.

Reported-by: Andrew Nesbit
Closes curl#21533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants