From: Remi Gacogne Date: Thu, 14 Mar 2019 15:32:50 +0000 (+0100) Subject: dnsdist: Prevent 0-TTL cache hits X-Git-Tag: dnsdist-1.4.0-alpha1~32^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07a262c6f6392510a5c6405a80eb1ce57e802702;p=pdns dnsdist: Prevent 0-TTL cache hits --- diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc index 8c6f86f7c..5b31ddfba 100644 --- a/pdns/dnsdist-cache.cc +++ b/pdns/dnsdist-cache.cc @@ -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(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--;