Make PackDomainName return error if the root label doesn't fit#1702
Merged
miekg merged 4 commits intomiekg:masterfrom Jan 22, 2026
Merged
Make PackDomainName return error if the root label doesn't fit#1702miekg merged 4 commits intomiekg:masterfrom
miekg merged 4 commits intomiekg:masterfrom
Conversation
miekg
reviewed
Jan 21, 2026
msg_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func TestPackDomainNameBufferSize(t *testing.T) { |
Owner
There was a problem hiding this comment.
there is no other test where a single extra case can be added?
Contributor
Author
There was a problem hiding this comment.
I don't think so. There are a couple tests in parse_test.go but none that could be just extended with the new case.
If you prefer that, I could move the unit to parse_test.go and/or limit it to checking just this edge case with no space for the root label.
Owner
There was a problem hiding this comment.
then just remove it, there are already too many tests that may or may not be actually testing something sane
miekg
reviewed
Jan 21, 2026
msg.go
Outdated
| if off < len(msg) { | ||
| msg[off] = 0 | ||
| off += 1 | ||
| } else { |
Contributor
Author
There was a problem hiding this comment.
Question of coding style. I've updated this.
Contributor
Author
|
Thank you! |
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.
At the moment, if the buffer provided to PackDomainName doesn't fit the trailing root label for the name, the function will skip writing the root label however it will return an adjusted offset and no error.
I believe this is a bug and not intentional behavior because it would be really confusing.
Here is a small reproducer:
I'm providing a fix that will make the function return an error if the buffer doesn't fit the root label. A unit test is included as well.