Skip to content

Commit

Permalink
make copies of RRs before returning them (coredns#4409)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris O'Haver <[email protected]>
  • Loading branch information
chrisohaver authored Jan 21, 2021
1 parent 95622f4 commit 8b2ff6c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugin/file/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8b2ff6c

Please sign in to comment.