mirror of
https://github.com/coredns/coredns.git
synced 2025-10-26 13:51:05 +01:00
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: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
117a389e40
commit
03812bb1e7
@ -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.
|
||||
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
|
||||
if r.ResponseRewrite {
|
||||
for _, rr := range res.Answer {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user