Skip to content

Commit 8775802

Browse files
committed
Use cloneMsg instead of shallow Copy for cached DNS messages
miekg/dns/v2 Msg.Copy() only does a useless shallow copy of the RR slices, so use cloneMsg instead.
1 parent df3ba8e commit 8775802

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

dnscrypt-proxy/plugin_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (plugin *PluginCache) Eval(pluginsState *PluginsState, msg *dns.Msg) error
7979
return nil
8080
}
8181
expiration := cached.expiration
82-
synth := cached.msg.Copy()
82+
synth := cloneMsg(cached.msg)
8383

8484
synth.ID = msg.ID
8585
synth.Response = true
@@ -141,7 +141,7 @@ func (plugin *PluginCacheResponse) Eval(pluginsState *PluginsState, msg *dns.Msg
141141
)
142142
cachedResponse := CachedResponse{
143143
expiration: time.Now().Add(ttl),
144-
msg: msg.Copy(),
144+
msg: cloneMsg(msg),
145145
}
146146
var cacheInitError error
147147
cachedResponses.cacheOnce.Do(func() {

0 commit comments

Comments
 (0)