-
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
Limit $GENERATE range to 65535 steps #1020
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1020 +/- ##
==========================================
+ Coverage 54.78% 55.27% +0.49%
==========================================
Files 41 41
Lines 9867 9973 +106
==========================================
+ Hits 5406 5513 +107
+ Misses 3435 3431 -4
- Partials 1026 1029 +3
Continue to review full report at Codecov.
|
Having these checks means all test in TestCrasherString() are not reached because we bail out earlier - removed that test all together. Fixes #1019 Signed-off-by: Miek Gieben <[email protected]>
done. PTAL |
@@ -49,14 +49,14 @@ func (zp *ZoneParser) generate(l lex) (RR, bool) { | |||
if err != nil { | |||
return zp.setParseError("bad stop in $GENERATE range", l) | |||
} | |||
if end < 0 || start < 0 || end < start { | |||
if end < 0 || start < 0 || end < start || (end-start)/step > 65535 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment in #1019 (comment) to align this with BIND behaviour. TL;DR both start and stop must be positive integers between 0 and (2^31)-1
generate_test.go
Outdated
{"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"}, | ||
{"$GENERATE 0-5414137360", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:22"}, | ||
{"$GENERATE 11522-3668518066406258", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:38"}, | ||
{"$GENERATE 0-200\"(;00000000000000\n$$GENERATE 0-0", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:16"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of those test were generating different errors, like timeout (I believe the second test was a timeout). Let me find the original error they were triggering.
err string | ||
}{ | ||
{"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"}, | ||
{"$GENERATE 0-5414137360", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:22"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
original error: program hanged (timeout 10 seconds)
[ Quoting <[email protected]> in "Re: [miekg/dns] Limit $GENERATE ran..." ]
chantra commented on this pull request.
>
-func TestCrasherString(t *testing.T) {
- tests := []struct{
- in string
- err string
-}{
- {"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"},
- {"$GENERATE 0-5414137360", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:22"},
original error: `program hanged (timeout 10 seconds)`
yes, with only 2^16-1 we don't hit this - I think the bind limits are a bit
crazy
|
in string | ||
err string | ||
}{ | ||
{"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtime: goroutine stack exceeds 1000000000-byte limit fatal error: stack overflow
}{ | ||
{"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"}, | ||
{"$GENERATE 0-5414137360", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:22"}, | ||
{"$GENERATE 11522-3668518066406258", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:38"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
program hanged (timeout 10 seconds)
{"$GENERATE 0-300103\"$$GENERATE 2-2", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:19"}, | ||
{"$GENERATE 0-5414137360", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:22"}, | ||
{"$GENERATE 11522-3668518066406258", "dns: garbage after $GENERATE range: \"\\n\" at line: 1:38"}, | ||
{"$GENERATE 0-200\"(;00000000000000\n$$GENERATE 0-0", "dns: garbage after $GENERATE range: \"\\\"\" at line: 1:16"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic: runtime error: index out of range [2048] with length 2048
@chantra happy to merge this as it now? |
sure, I would be tempted to leave test case that catch garbage after the range/step token though :) |
Signed-off-by: Miek Gieben <[email protected]>
Signed-off-by: Miek Gieben <[email protected]>
ok, adding that back in |
While the range number of GENERATE is now limited, one can pass a line with 2 $GENERATE directive that will exponentially increase the time spent generating RRs. Limit to only one per line. Fixes miekg#1020
While the range number of GENERATE is now limited, one can pass a line with 2 $GENERATE directive that will exponentially increase the time spent generating RRs. Limit to only one per line. Fixes miekg#1020
While the range number of GENERATE is now limited, one can pass a line with 2 $GENERATE directive that will exponentially increase the time spent generating RRs. Limit to only one per line. Fixes miekg#1020
While the range number of GENERATE is now limited, one can pass a line with 2 $GENERATE directive that will exponentially increase the time spent generating RRs. Limit to only one per line. Fixes #1020
* Limit $GENERATE range to 65535 steps Having these checks means all test in TestCrasherString() are not reached because we bail out earlier - removed that test all together. Fixes miekg#1019 Signed-off-by: Miek Gieben <[email protected]> * bring back testcase Signed-off-by: Miek Gieben <[email protected]> * bring back crash test Signed-off-by: Miek Gieben <[email protected]>
While the range number of GENERATE is now limited, one can pass a line with 2 $GENERATE directive that will exponentially increase the time spent generating RRs. Limit to only one per line. Fixes miekg#1020
Fixes #1019