]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add the d_orig_ttl sanitization back, there still is a case where 12673/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 30 May 2023 14:02:15 +0000 (16:02 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 30 May 2023 14:02:15 +0000 (16:02 +0200)
it can wrap (which I'm unable to spot right now).

pdns/recursordist/recursor_cache.cc

index 8b5b72f908c67764d649fa1c2605e637068aac8b..0d237cd750895b0c31fc60ec33dfd806c5e5642b 100644 (file)
@@ -609,6 +609,12 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt,
     ce.d_ttd = min(maxTTD, static_cast<time_t>(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());
   }