From 39a219755c5fb174acbe3bee0d1b286e9b1e703f Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 29 Dec 2016 11:46:36 +0100 Subject: [PATCH] dnsdist: Check that cached responses are >= sizeof(dnsheader) The check is done before inserting the response into the cache, but it feels safer to check it again before passing it to `memcpy()`. We check that the cached response is larger than `sizeof(dnsheader) + qname` afterwards, but the previous commit moved the header copy before that check. --- pdns/dnsdist-cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc index e36fa5d451..2b9c25cc49 100644 --- a/pdns/dnsdist-cache.cc +++ b/pdns/dnsdist-cache.cc @@ -156,7 +156,7 @@ bool DNSDistPacketCache::get(const DNSQuestion& dq, uint16_t consumed, uint16_t } } - if (*responseLen < value.len) { + if (*responseLen < value.len || value.len < sizeof(dnsheader)) { return false; } -- 2.47.2