From 623de14ebb299b08d20d14f9115c14522ddd8999 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 13 Dec 2012 10:14:22 +0100 Subject: [PATCH] Add missing checks if $ORIGIN's name is valid Call IsDomainName() as $ORIGIN is rel. infrequent this does not impact the parsing speed. --- zscan.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zscan.go b/zscan.go index fc4e1d09..903b806b 100644 --- a/zscan.go +++ b/zscan.go @@ -252,6 +252,10 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) { case _BLANK: l := <-c if l.value == _STRING { + if _, _, ok := IsDomainName(l.token); !ok { + t <- Token{Error: &ParseError{f, "bad origin name", l}} + return + } // a new origin is specified. if !IsFqdn(l.token) { if origin != "." { // Prevent .. endings @@ -317,6 +321,10 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) { if e := slurpRemainder(c, f); e != nil { t <- Token{Error: e} } + if _, _, ok := IsDomainName(l.token); !ok { + t <- Token{Error: &ParseError{f, "bad origin name", l}} + return + } if !IsFqdn(l.token) { if origin != "." { // Prevent .. endings origin = l.token + "." + origin