[plugin/cache] create a copy of a response to ensure original data is never modified (#7357)

Signed-off-by: Oleg Guba <oleg.guba@gmail.com>
This commit is contained in:
Oleg Guba
2025-06-06 05:14:41 -07:00
committed by GitHub
parent 6cba588951
commit 27273a3a26

View File

@@ -182,6 +182,7 @@ func (w *ResponseWriter) RemoteAddr() net.Addr {
// WriteMsg implements the dns.ResponseWriter interface.
func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
res = res.Copy()
mt, _ := response.Typify(res, w.now().UTC())
// key returns empty string for anything we don't want to cache.