Repository navigation
Conversation
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
approved these changes
Sep 1, 2026
There was a problem hiding this comment.
🟢 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 < 3indoh_rdata()and returnDOH_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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.