]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Check that cached responses are >= sizeof(dnsheader) 4812/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Dec 2016 10:46:36 +0000 (11:46 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Dec 2016 10:56:25 +0000 (11:56 +0100)
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

index e36fa5d451b413b72410f841182188649ab9bfa6..2b9c25cc49fae2ae1dcf38894ac62a7056094661 100644 (file)
@@ -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;
     }