diff options
author | 2016-09-24 10:51:20 -0400 | |
---|---|---|
committer | 2016-09-24 15:51:20 +0100 | |
commit | ec485a74d327d275f7cdadfb1ff70f7f30421aac (patch) | |
tree | 7b93935e47316f037c5c7e34c5047b8f40d06eab | |
parent | 15297c8e637927500902e848ac73bd510cd4c49e (diff) | |
download | coredns-ec485a74d327d275f7cdadfb1ff70f7f30421aac.tar.gz coredns-ec485a74d327d275f7cdadfb1ff70f7f30421aac.tar.zst coredns-ec485a74d327d275f7cdadfb1ff70f7f30421aac.zip |
Nil SOA causes panic if we compare it to incoming SOA (#291)
-rw-r--r-- | middleware/file/secondary.go | 3 | ||||
-rw-r--r-- | middleware/file/secondary_test.go | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/middleware/file/secondary.go b/middleware/file/secondary.go index 6f5d9ef4a..70ec217f7 100644 --- a/middleware/file/secondary.go +++ b/middleware/file/secondary.go @@ -88,6 +88,9 @@ Transfer: if serial == -1 { return false, Err } + if z.Apex.SOA == nil { + return true, Err + } return less(z.Apex.SOA.Serial, uint32(serial)), Err } diff --git a/middleware/file/secondary_test.go b/middleware/file/secondary_test.go index b32c7aca7..6f45a61bb 100644 --- a/middleware/file/secondary_test.go +++ b/middleware/file/secondary_test.go @@ -84,9 +84,17 @@ func TestShouldTransfer(t *testing.T) { z.origin = testZone z.TransferFrom = []string{addrstr} + // when we have a nil SOA (initial state) + should, err := z.shouldTransfer() + if err != nil { + t.Fatalf("unable to run shouldTransfer: %v", err) + } + if !should { + t.Fatalf("shouldTransfer should return true for serial: %d", soa.serial) + } // Serial smaller z.Apex.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial-1)) - should, err := z.shouldTransfer() + should, err = z.shouldTransfer() if err != nil { t.Fatalf("unable to run shouldTransfer: %v", err) } |