]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
As found by coverity, origTTL can be left uninitialized if all the entries found...
authorOtto <otto.moerbeek@open-xchange.com>
Wed, 13 Jan 2021 09:18:47 +0000 (10:18 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 13 Jan 2021 09:18:47 +0000 (10:18 +0100)
In that case the loop exits without setting origTTL via handleHit().

pdns/recursor_cache.cc
pdns/recursor_cache.hh

index bc63003ffebfa752dc6550ee9c4703488e16fd70..32f6e357386f31218d659355b95882b8a38e2272 100644 (file)
@@ -318,7 +318,7 @@ int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt,
     else {
       auto entry = getEntryUsingECSIndex(map, now, qname, qtype, requireAuth, who);
       if (entry != map.d_map.end()) {
-          int32_t ret = handleHit(map, entry, qname, origTTL, res, signatures, authorityRecs, variable, cachedState, wasAuth, fromAuthZone);
+        int32_t ret = handleHit(map, entry, qname, origTTL, res, signatures, authorityRecs, variable, cachedState, wasAuth, fromAuthZone);
         if (state && cachedState) {
           *state = *cachedState;
         }
@@ -336,6 +336,7 @@ int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt,
       for (auto i=entries.first; i != entries.second; ++i) {
 
         firstIndexIterator = map.d_map.project<OrderedTag>(i);
+        origTTL = firstIndexIterator->d_orig_ttl;
         if (i->d_ttd <= now) {
           moveCacheItemToFront<SequencedTag>(map.d_map, firstIndexIterator);
           continue;
@@ -365,6 +366,7 @@ int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt,
     for (auto i=entries.first; i != entries.second; ++i) {
 
       firstIndexIterator = map.d_map.project<OrderedTag>(i);
+      origTTL = firstIndexIterator->d_orig_ttl;
       if (i->d_ttd <= now) {
         moveCacheItemToFront<SequencedTag>(map.d_map, firstIndexIterator);
         continue;
@@ -392,7 +394,7 @@ void MemRecursorCache::replace(time_t now, const DNSName &qname, const QType& qt
 {
   auto& map = getMap(qname);
   const lock l(map);
-  
+
   map.d_cachecachevalid = false;
   if (ednsmask) {
     ednsmask = ednsmask->getNormalized();
index f9ab3601aeddf9652df6c866fcdfab15d70b982d..df46c728d14c59adc1025c23826a963988050b1e 100644 (file)
@@ -75,7 +75,7 @@ private:
   struct CacheEntry
   {
     CacheEntry(const boost::tuple<DNSName, uint16_t, OptTag, Netmask>& key, bool auth):
-      d_qname(key.get<0>()), d_netmask(key.get<3>().getNormalized()), d_rtag(key.get<2>()), d_state(vState::Indeterminate), d_ttd(0), d_qtype(key.get<1>()), d_auth(auth)
+      d_qname(key.get<0>()), d_netmask(key.get<3>().getNormalized()), d_rtag(key.get<2>()), d_state(vState::Indeterminate), d_ttd(0), d_qtype(key.get<1>()), d_auth(auth), d_submitted(false)
     {
     }