Repository navigation
Conversation
dnsmessage.NewName only checks the 255-byte total, so a name with one 64-byte label passed the invalid-name branch, took a connection and a query slot from the rate budget, and only failed when the message was built. Classify then reported OutcomeOther instead of not-found, which nudged the reliability guard for a name that should simply be skipped. The branch now splits the name and rejects any label over 63 bytes, so the lookup returns a not-found *net.DNSError without dialing. The existing test pinned only the over-255-byte case; it now pins this one too, including the connection and wire counters.
Owner
|
Thanks for this, and for the clear write-up. Your diagnosis is right: #344 was fixed on main in 9fc7b21 while this PR was open, so this branch now conflicts. That fix does the same thing. It adds a Main already has everything this PR adds, so I'm closing it rather than asking for a rebase. Thanks again. Contributions like this are very welcome. |
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.
Problem
Fixes #344. A name with a label over 63 bytes is meant to be skipped as not found without any query, but the guard in
lookupCNAMEonly caught names over the 255 bytesdnsmessage.NewNamerejects. A 64-byte label passed it, so the lookup dialed, took a rate slot and a query, then failed building the question and was counted asOutcomeOther— an infrastructure failure — instead of not-found.Root cause
dnsmessage.NewNamevalidates the 255-byte total length of a name, not the 63-byte limit of a single label. The invalid-name branch ininternal/dns/cname.goreturned the not-found error only whenNewNamefailed, so the over-long-label case fell through tocnameExchange, which dialed beforecnameQueryrefused to build the message.Fix
lookupCNAMEnow also runslongLabelon the name before dialing: any label over 63 bytes returns the same not-found*net.DNSErrorthe other invalid names get, soClassifyreportsOutcomeNXDomainand no connection, write or query happens. The check splits the name on dots, so a trailing dot and the existing name forms are unaffected.Testing
go test ./internal/dns/ -run TestCNAMEInvalidNameSendsNoQuery -v— the acceptance case for CNAME lookup of a 64-byte label dials, then reports an error, not not-found #344 is now pinned inTestCNAMEInvalidNameSendsNoQuery: a 64-byte label returns not-found,ClassifygivesOutcomeNXDomain, and the connection, write and query counters stay at 0. Without the source change the test fails with1 connections, want 0, so it guards the branch.go test ./internal/dns/andgo test ./...— pass.gofmt -landgo vet ./internal/dns/— clean.