From: Otto Moerbeek Date: Tue, 30 May 2023 14:02:15 +0000 (+0200) Subject: Add the d_orig_ttl sanitization back, there still is a case where X-Git-Tag: rec-4.9.0-beta1~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12673%2Fhead;p=thirdparty%2Fpdns.git Add the d_orig_ttl sanitization back, there still is a case where it can wrap (which I'm unable to spot right now). --- diff --git a/pdns/recursordist/recursor_cache.cc b/pdns/recursordist/recursor_cache.cc index 8b5b72f908..0d237cd750 100644 --- a/pdns/recursordist/recursor_cache.cc +++ b/pdns/recursordist/recursor_cache.cc @@ -609,6 +609,12 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, ce.d_ttd = min(maxTTD, static_cast(i.d_ttl)); // XXX this does weird things if TTLs differ in the set ce.d_orig_ttl = ce.d_ttd - ttl_time; + // Even though we record the time the ttd was computed, there still seems to be a case where the computed + // d_orig_ttl can wrap. + // So santize the computed ce.d_orig_ttl to be on the safe side + if (ce.d_orig_ttl < SyncRes::s_minimumTTL || ce.d_orig_ttl > SyncRes::s_maxcachettl) { + ce.d_orig_ttl = SyncRes::s_minimumTTL; + } ce.d_records.push_back(i.getContent()); }