-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Packing overflow / compression bug #67
Comments
Might be barking up the wrong tree here but I think the root cause of this might be the packed length of RRs being miscalculated. In this case the length of the NAPTR record is off by a few bytes as it doesn't include the length bytes for
To:
It should pack okay without compression. I'll take another pass at this tomorrow if @miekg doesn't beat me to it. |
I was barking up the wrong tree! The length bytes would have gone in place of periods in I think I know why swapping in |
The packLen() function returns the wrong length, which in turns means that some (NAPTR seems an obvious choice) RR returns the wrong length. packLen() is kind of a premature optimization in that tries to get the package length without actually packing it. Doing something ridiculous in msg.go L1347:
Fixes the problem. Actually tracking down which RR is doing this is quite annoying, but I'll check, |
Add the 3 bytes for the length byte of the strings. Close issue #67.
@andrewtj you're comment was almost spot on, the string need a lenght byte and the NAPTR's len function didn't take this into account. Fixed this and added a test. The test program now works OK even with |
In some cases, I'm using the client to act like a recursive DNS server. However, with some queries, I get the following:
It seems to have to do with something in the response body. I have a minimal test case here: https://gist.github.com/armon/8248769
Once you run that server, use the following dig command:
Inside the test case, there is a line with a comment to toggle the value. The compression flag on the response seems to change if this works. With compression enabled, the response goes through fine. Without compression, the packing error happens.
The text was updated successfully, but these errors were encountered: