]> granicus.if.org Git - pdns/commitdiff
dnsdist: Prevent 0-TTL cache hits
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 14 Mar 2019 15:32:50 +0000 (16:32 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 14 Mar 2019 15:32:50 +0000 (16:32 +0100)
pdns/dnsdist-cache.cc

index 8c6f86f7cd59740f79929b5813b16525f155efa0..5b31ddfbad898e97b5858e03fb733c0cbd3e60d5 100644 (file)
@@ -233,7 +233,7 @@ bool DNSDistPacketCache::get(const DNSQuestion& dq, uint16_t consumed, uint16_t
     }
 
     const CacheValue& value = it->second;
-    if (value.validity < now) {
+    if (value.validity <= now) {
       if ((now - value.validity) >= static_cast<time_t>(allowExpired)) {
         d_misses++;
         return false;
@@ -313,7 +313,7 @@ void DNSDistPacketCache::purgeExpired(size_t upTo)
     for(auto it = map.begin(); toRemove > 0 && it != map.end(); ) {
       const CacheValue& value = it->second;
 
-      if (value.validity < now) {
+      if (value.validity <= now) {
         it = map.erase(it);
         --toRemove;
         d_shards[shardIndex].d_entriesCount--;