Commit 03812bb1 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

plugin/rewrite: copy msg before rewritting (#4443)

Copy the msg to prevent messing with the (via the pointer) original
created message that may be stored in the cache or anything other data
store.
Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
parent 117a389e
...@@ -36,7 +36,10 @@ func NewResponseReverter(w dns.ResponseWriter, r *dns.Msg) *ResponseReverter { ...@@ -36,7 +36,10 @@ func NewResponseReverter(w dns.ResponseWriter, r *dns.Msg) *ResponseReverter {
} }
// WriteMsg records the status code and calls the underlying ResponseWriter's WriteMsg method. // WriteMsg records the status code and calls the underlying ResponseWriter's WriteMsg method.
func (r *ResponseReverter) WriteMsg(res *dns.Msg) error { func (r *ResponseReverter) WriteMsg(res1 *dns.Msg) error {
// Deep copy 'res' as to not (e.g). rewrite a message that's also stored in the cache.
res := res1.Copy()
res.Question[0] = r.originalQuestion res.Question[0] = r.originalQuestion
if r.ResponseRewrite { if r.ResponseRewrite {
for _, rr := range res.Answer { for _, rr := range res.Answer {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment