Fuzzing the text parser: a few fixes (#579)
I'm fuzzing the text parser and that turned up these two. Will do further fuzzing with these fixes in.
This commit is contained in:
parent
7994cb36ea
commit
acff9ce3fa
|
@ -1428,3 +1428,20 @@ func TestUnbalancedParens(t *testing.T) {
|
|||
t.Fatalf("failed to detect extra opening brace")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBad(t *testing.T) {
|
||||
tests := []string{
|
||||
`" TYPE257 9 1E12\x00\x105"`,
|
||||
`" TYPE256 9 5"`,
|
||||
`" TYPE257 0\"00000000000000400000000000000000000\x00\x10000000000000000000000000000000000 9 l\x16\x01\x005266"`,
|
||||
}
|
||||
for i := range tests {
|
||||
s, err := strconv.Unquote(tests[i])
|
||||
if err != nil {
|
||||
t.Fatalf("failed to unquote: %q: %s", tests[i], err)
|
||||
}
|
||||
if _, err = NewRR(s); err == nil {
|
||||
t.Errorf("correctly parsed %q", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1797,7 +1797,7 @@ func setURI(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
|||
if err != nil {
|
||||
return nil, err, ""
|
||||
}
|
||||
if len(s) > 1 {
|
||||
if len(s) != 1 {
|
||||
return nil, &ParseError{f, "bad URI Target", l}, ""
|
||||
}
|
||||
rr.Target = s[0]
|
||||
|
@ -2027,7 +2027,7 @@ func setCAA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
|||
if e != nil {
|
||||
return nil, e, ""
|
||||
}
|
||||
if len(s) > 1 {
|
||||
if len(s) != 1 {
|
||||
return nil, &ParseError{f, "bad CAA Value", l}, ""
|
||||
}
|
||||
rr.Value = s[0]
|
||||
|
|
Loading…
Reference in New Issue