make copies of RRs before returning them (#4409)

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2021-01-21 03:59:58 -05:00 committed by GitHub
parent 95622f4c9a
commit 8b2ff6c388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -171,7 +171,12 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
return z.externalLookup(ctx, state, elem, rrs)
}
rrs := elem.Type(qtype)
treeRRs := elem.Type(qtype)
// make a copy of the element RRs to prevent response writers from mutating the tree
rrs := make([]dns.RR, len(treeRRs))
for i, rr := range treeRRs {
rrs[i] = dns.Copy(rr)
}
// NODATA
if len(rrs) == 0 {