plugin/file: stop self-referential DNAME loops (#8418)

This commit is contained in:
houyuwushang
2026-08-11 04:26:01 +08:00
committed by GitHub
parent c2ca1b2c23
commit ea2eea57a7
2 changed files with 45 additions and 11 deletions

View File

@@ -118,6 +118,11 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
// Only one DNAME is allowed per name. We just pick the first one to synthesize from.
dname := dnamerrs[0]
if cname := synthesizeCNAME(state.Name(), dname.(*dns.DNAME)); cname != nil {
// A DNAME substitution that does not change the name can only loop.
if dns.CanonicalName(cname.Hdr.Name) == dns.CanonicalName(cname.Target) {
return nil, nil, nil, ServerFailure
}
var (
answer, ns, extra []dns.RR
rcode Result