Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bail early from UnpackDomainName when name is too long #839

Merged
merged 7 commits into from
Nov 28, 2018

Conversation

tmthrgd
Copy link
Collaborator

@tmthrgd tmthrgd commented Nov 28, 2018

This PR drastically reduces the amount of garbage created in UnpackDomainName for certain malicious names.

The wire formatted name

"\x3Faaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuu\xC0\x00"

would previously generate 1936B of garbage before #835, and 36112B of garbage since #835, before returning the "too many compression pointers" error, while after this PR it will generate just 384B of garbage before returning the error.

Related #835
Fixes #836

This drastically reduces the amount of garbage created
in UnpackDomainName for certain malicious names.

The wire formatted name
 "\x3Faaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuu\xC0\x00"
would previously generate 1936B of garbage (36112B since maxCompressionPointers
was raised) before returning the "too many compression pointers" error, while
it now generates just 384B of garbage.
This better reflects what maxDomainNameWireOctets is actually measuring.
@tmthrgd tmthrgd requested a review from miekg November 28, 2018 12:42
@tmthrgd
Copy link
Collaborator Author

tmthrgd commented Nov 28, 2018

/cc @semihalev

@codecov-io
Copy link

codecov-io commented Nov 28, 2018

Codecov Report

Merging #839 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #839      +/-   ##
==========================================
+ Coverage   57.87%   57.92%   +0.04%     
==========================================
  Files          42       42              
  Lines       10820    10830      +10     
==========================================
+ Hits         6262     6273      +11     
  Misses       3473     3473              
+ Partials     1085     1084       -1
Impacted Files Coverage Δ
msg.go 78.94% <ø> (+0.5%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bf402f...ebbdf6e. Read the comment docs.

This can never be tripped as budget is always checked immediately after
subtracting inside the loop.
msg.go Show resolved Hide resolved
@tmthrgd tmthrgd mentioned this pull request Nov 28, 2018
msg.go Show resolved Hide resolved
@miekg
Copy link
Owner

miekg commented Nov 28, 2018

/lgtm apart from the one nit

@miekg
Copy link
Owner

miekg commented Nov 28, 2018 via email

@tmthrgd tmthrgd merged commit 6aa28be into miekg:master Nov 28, 2018
@tmthrgd tmthrgd deleted the unpack-name-garbage branch November 28, 2018 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants