From 90fb201a51db3e1a0958d46db9ecfaa2e8fc0d51 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 16 Jun 2015 16:45:22 +0100 Subject: [PATCH] Copy the DNS entry going into the cache, to avoid races. The shuffleAnswers() call ends up acting on the same data, so it seems simplest to resolve ownership arguments by copying. --- nameserver/cache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nameserver/cache.go b/nameserver/cache.go index c65824ed..4af548c8 100644 --- a/nameserver/cache.go +++ b/nameserver/cache.go @@ -155,7 +155,7 @@ func (e *cacheEntry) setReply(reply *dns.Msg, ttl int, flags uint8, now time.Tim e.putTime = now if reply != nil { - e.reply = *reply + e.reply = *reply.Copy() e.ReplyLen = reply.Len() }