Skip to content

doh: reject undersized HTTPS RDATA - #22791

Closed
cmeister2 wants to merge 1 commit into
masterfrom
cm2/doh
Closed

cmeister2 wants to merge 1 commit into
masterfrom
cm2/doh

Conversation

@cmeister2

Copy link
Copy Markdown
Contributor

HTTPS RDATA requires at least two bytes for SvcPriority and one byte for TargetName. Reject shorter records before storing them to avoid zero-sized allocations in debug builds.

Add unit coverage for RDATA lengths zero through three.

@github-actions github-actions Bot added the tests label Sep 1, 2026
HTTPS RDATA requires at least two bytes for SvcPriority and one byte
for TargetName. Reject shorter records before storing them to avoid
zero-sized allocations in debug builds.

Add unit coverage for RDATA lengths zero through three.

Closes #22791
@bagder
bagder requested a lite review from Copilot September 1, 2026 22:12
@bagder bagder added the name lookup DNS and related tech label Sep 1, 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.

🟢 Approval recommended

The change is minimal, localized, matches the stated requirement, and includes targeted unit coverage for the new validation behavior.

Pull request overview

This PR tightens DoH HTTPS RR parsing in lib/vdns/doh.c by rejecting undersized HTTPS RDATA (minimum 3 bytes: 2-byte SvcPriority + 1-byte TargetName) before attempting to store it, preventing zero-length allocations; it also adds unit coverage for RDATA lengths 0–3 to lock in the behavior.

Changes:

  • Reject HTTPS RDATA with rdlength < 3 in doh_rdata() and return DOH_DNS_RDATA_LEN.
  • Simplify HTTPS RR handling by returning doh_store_https() directly once the minimum-length check passes.
  • Add a unit test that exercises HTTPS RR RDATA lengths 0, 1, 2 (expect error) and 3 (expect success and one stored RR).
File summaries
File Description
tests/unit/unit1650.c Adds a focused unit test for HTTPS RR RDATA lengths 0–3 to validate the new rejection threshold.
lib/vdns/doh.c Adds a minimum-length guard for HTTPS RDATA and returns early to avoid storing undersized records.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@bagder bagder closed this in 5bbff5c Sep 2, 2026
@bagder
bagder deleted the cm2/doh branch September 2, 2026 07:30
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.

3 participants