fix(dnssec): add defensive nil checks (#7997)

This commit is contained in:
Ville Vesilehto
2026-04-02 00:19:54 +03:00
committed by GitHub
parent 503c2d7ea3
commit 6d6c50db3a

View File

@@ -48,6 +48,9 @@ func (d Dnssec) Sign(state request.Request, now time.Time, server string) *dns.M
mt, _ := response.Typify(req, time.Now().UTC()) // TODO(miek): need opt record here? mt, _ := response.Typify(req, time.Now().UTC()) // TODO(miek): need opt record here?
if mt == response.Delegation { if mt == response.Delegation {
if len(req.Ns) == 0 {
return req
}
// We either sign DS or NSEC of DS. // We either sign DS or NSEC of DS.
ttl := req.Ns[0].Header().Ttl ttl := req.Ns[0].Header().Ttl
@@ -68,7 +71,7 @@ func (d Dnssec) Sign(state request.Request, now time.Time, server string) *dns.M
} }
if mt == response.NameError || mt == response.NoData { if mt == response.NameError || mt == response.NoData {
if req.Ns[0].Header().Rrtype != dns.TypeSOA || len(req.Ns) > 1 { if len(req.Ns) != 1 || req.Ns[0].Header().Rrtype != dns.TypeSOA {
return req return req
} }