Repository navigation
dnscache: compare full hostnames when lookup keys are truncated - #23350
Closed
cla7aye15I4nd wants to merge 5 commits into
Closed
cla7aye15I4nd wants to merge 5 commits into
cla7aye15I4nd wants to merge 5 commits into
Conversation
vszakats
requested changes
Oct 11, 2026
cla7aye15I4nd
marked this pull request as ready for review
October 11, 2026 08:18
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly handles truncated keys and includes appropriate regression tests.
0 open findings
What changed in this PR
Hardens DNS cache lookup against collisions caused by truncated hostname keys.
Changes:
- Requires full hostname comparison when either cache key is truncated.
- Adds tests for long-hostname ordering, equality, and case insensitivity.
| File | Description |
|---|---|
lib/vdns/dnscache.c |
Corrects truncated-key hostname matching. |
tests/unit/unit3271.c |
Adds long-hostname regression coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
icing
approved these changes
Oct 13, 2026
icing
left a comment
Contributor
There was a problem hiding this comment.
Good catch. I only fixed the one direction.
jay
reviewed
Oct 13, 2026
Co-authored-by: Jay Satiro <raysatiro@yahoo.com>
Prepare the short cached hostname in the local array to avoid a constant out-of-bounds subscript on the trailing one-element member. Validation: macOS arm64 AppleClang 21 Debug unit3271 passes; checksrc and git diff --check pass. CURL_WERROR enabled with an exception for an unrelated socketpair.c unreachable-code warning. Older MinGW validation is left to CI.
jay
approved these changes
Oct 14, 2026
Member
|
Thanks |
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.
A cached 255-byte hostname can match a longer hostname sharing the truncated hash key. Require both names to fit the key before using the fast path; otherwise compare the complete case-insensitive hostname. Extend unit3271 with both length orderings and equal long names.
Validation: unit3271 passes. A local HTTP reproducer using a 255-byte CURLOPT_RESOLVE entry no longer receives a request for the longer
.evilhostname (CURLE_COULDNT_RESOLVE_HOST). Existing resolve tests pass.Prepared against upstream master (
b8f71d6e1199701352c498467c17847237d1c43e). AI-assisted patch, independently reviewed and tested locally. Source-format checks pass; cross-platform CI remains to be reviewed.