Skip to content

dnsd: fix bounds check in read_https_alpn_part() - #22420

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:dnsd-bounds
Closed

dnsd: fix bounds check in read_https_alpn_part()#22420
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:dnsd-bounds

Conversation

@vszakats

@vszakats vszakats commented Jul 28, 2026

Copy link
Copy Markdown
Member

"The check i > 256 permits i == 256 to pass through. When i is
then cast to uint8_t in blob_add(b, (uint8_t)i), the value wraps to
0, silently encoding a zero-length ALPN entry instead of rejecting it.
The condition should be i > 255 (or equivalently i >= 256) to
correctly reject any length that does not fit in a single byte."

Reported by GitHub Code Quality

Follow-up to 86f1e5b #21299

"The check `i > 256` permits `i == 256` to pass through. When `i` is
then cast to `uint8_t` in `blob_add(b, (uint8_t)i)`, the value wraps to
0, silently encoding a zero-length ALPN entry instead of rejecting it.
The condition should be `i > 255` (or equivalently `i >= 256`) to
correctly reject any length that does not fit in a single byte."

Reported by GitHub Code Quality
@vszakats vszakats added the tests label Jul 28, 2026
@github-actions github-actions Bot added the name lookup DNS and related tech label Jul 28, 2026
@vszakats
vszakats requested a review from Copilot July 28, 2026 19:50
@vszakats vszakats added HTTP/2 and removed HTTP/2 labels Jul 28, 2026

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 fixes an off-by-one bounds check in the test DNS server’s HTTPS ALPN parsing (read_https_alpn_part()), ensuring that ALPN entry lengths that do not fit in a single byte are correctly rejected instead of silently wrapping to zero.

Changes:

  • Reject i == 256 (and larger) ALPN part lengths by changing the check from i > 256 to i >= 256, preventing (uint8_t)i wraparound to 0.

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

@vszakats
vszakats requested a review from Copilot July 28, 2026 19:59
@vszakats vszakats changed the title dnsd: fix a bounds check in read_https_alpn_part() dnsd: fix bounds check in read_https_alpn_part() Jul 28, 2026

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 387b4c5 Jul 28, 2026
@vszakats
vszakats deleted the dnsd-bounds branch July 28, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

name lookup DNS and related tech tests

Development

Successfully merging this pull request may close these issues.

2 participants