From e4205768578dc90c2669e75a2f8a8bf77e3083a4 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 18 Aug 2017 14:14:42 +0100 Subject: [PATCH] scan: Fix $INCLUDE arguments to parseZone (#508) When an $INCLUDE was seen the arguments to parseZone where in the wrong order meaning the filename was used as the `neworigin` instead of the actual origin we need. Extend the testcase to check for the full name of the record. --- scan.go | 2 +- scan_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scan.go b/scan.go index 5f7f6442..a76f1d83 100644 --- a/scan.go +++ b/scan.go @@ -313,7 +313,7 @@ func parseZone(r io.Reader, origin, f string, t chan *Token, include int) { t <- &Token{Error: &ParseError{f, "too deeply nested $INCLUDE", l}} return } - parseZone(r1, l.token, neworigin, t, include+1) + parseZone(r1, neworigin, l.token, t, include+1) st = zExpectOwnerDir case zExpectDirTtlBl: if l.value != zBlank { diff --git a/scan_test.go b/scan_test.go index b31c4c77..e43ad447 100644 --- a/scan_test.go +++ b/scan_test.go @@ -21,13 +21,16 @@ func TestParseZoneInclude(t *testing.T) { t.Fatalf("could not close tmpfile %q: %s", tmpfile.Name(), err) } - zone := "$INCLUDE " + tmpfile.Name() + zone := "$ORIGIN example.org.\n$INCLUDE " + tmpfile.Name() tok := ParseZone(strings.NewReader(zone), "", "") for x := range tok { if x.Error != nil { t.Fatalf("expected no error, but got %s", x.Error) } + if x.RR.Header().Name != "foo.example.org." { + t.Fatalf("expected %s, but got %s", "foo.example.org.", x.RR.Header().Name) + } } os.Remove(tmpfile.Name())