Fix for when not seeing an RR at all
This commit is contained in:
parent
9cbe439ce3
commit
df6d86e937
|
@ -426,3 +426,24 @@ func ExampleSOA() {
|
||||||
fmt.Printf("%s\n", soa.String())
|
fmt.Printf("%s\n", soa.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLineNumberError(t *testing.T) {
|
||||||
|
s := "example.com. 1000 SOA master.example.com. admin.example.com. monkey 4294967294 4294967293 4294967295 100"
|
||||||
|
if _, err := NewRR(s); err != nil {
|
||||||
|
if err.Error() != "dns: bad SOA zone parameter: \"monkey\" at line: 1:68" {
|
||||||
|
t.Logf("Not expecting this error: " + err.Error())
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test with no known RR on the line
|
||||||
|
func TestLineNumberError2(t *testing.T) {
|
||||||
|
s := "example.com. 1000 SO master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100"
|
||||||
|
_, err := NewRR(s)
|
||||||
|
if err == nil {
|
||||||
|
t.Fail()
|
||||||
|
} else {
|
||||||
|
// fmt.Printf("%s\n", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
11
zscan.go
11
zscan.go
|
@ -23,7 +23,7 @@ const maxTok = 2048
|
||||||
// * Handle braces.
|
// * Handle braces.
|
||||||
const (
|
const (
|
||||||
// Zonefile
|
// Zonefile
|
||||||
_EOF = iota // Don't let it start with zero
|
_EOF = iota
|
||||||
_STRING
|
_STRING
|
||||||
_BLANK
|
_BLANK
|
||||||
_QUOTE
|
_QUOTE
|
||||||
|
@ -70,7 +70,7 @@ func (e *ParseError) Error() (s string) {
|
||||||
if e.file != "" {
|
if e.file != "" {
|
||||||
s = e.file + ": "
|
s = e.file + ": "
|
||||||
}
|
}
|
||||||
s += "dns:" + e.err + ": `" + e.lex.token + "' at line: " +
|
s += "dns: " + e.err + ": " + strconv.QuoteToASCII(e.lex.token) + " at line: " +
|
||||||
strconv.Itoa(e.lex.line) + ":" + strconv.Itoa(e.lex.column)
|
strconv.Itoa(e.lex.line) + ":" + strconv.Itoa(e.lex.column)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -343,6 +343,9 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
case _RRTYPE:
|
case _RRTYPE:
|
||||||
h.Rrtype = l.torc
|
h.Rrtype = l.torc
|
||||||
st = _EXPECT_RDATA
|
st = _EXPECT_RDATA
|
||||||
|
case _NEWLINE:
|
||||||
|
t <- Token{Error: &ParseError{f, "premature newline, no RR type seen", l}}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
case _EXPECT_ANY_NOCLASS:
|
case _EXPECT_ANY_NOCLASS:
|
||||||
switch l.value {
|
switch l.value {
|
||||||
|
@ -391,6 +394,10 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
st = _EXPECT_OWNER_DIR
|
st = _EXPECT_OWNER_DIR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If we get here, we and the h.Rrtype is still zero, we haven't parsed anything
|
||||||
|
if h.Rrtype == 0 {
|
||||||
|
t <- Token{Error: &ParseError{f, "nothing made sense", lex{}}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l lex) String() string {
|
func (l lex) String() string {
|
||||||
|
|
Loading…
Reference in New Issue