mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	middleware/secondary: fix crash with no zone (#680)
When CoreDNS starts up and can't get a zone transfer going the Apex is empty. This `nil` is then transformed into wireformat, which fails with a nil pointer dereference in Go DNS. In this case we should just return SERVFAIL, because we don't have any info (yet). Note the lookup code returned NXDOMAIN, which is correct from a lookup standpoint, but also invalidates every name in the future loaded zone. Anyway, look for an apex before doing the lookup and return SERVFAIL if nothing is found. Fixes #679
This commit is contained in:
		| @@ -39,6 +39,14 @@ func (z *Zone) Lookup(state request.Request, qname string) ([]dns.RR, []dns.RR, | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	// If z is a secondary zone we might not have transfered it, meaning we have | ||||
| 	// all zone context setup, except the actual record. This means (for one thing) the apex | ||||
| 	// is empty and we don't have a SOA record. | ||||
| 	soa := z.Apex.SOA | ||||
| 	if soa == nil { | ||||
| 		return nil, nil, nil, ServerFailure | ||||
| 	} | ||||
|  | ||||
| 	if qtype == dns.TypeSOA { | ||||
| 		return z.soa(do), z.ns(do), nil, Success | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user