]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Scanbuid fixes
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 25 Mar 2022 10:17:44 +0000 (11:17 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 28 Mar 2022 08:59:58 +0000 (10:59 +0200)
AFAIKS, a few false positives remain:

Unused code Dead assignment lwres.cc asyncresolve 444 1 View Report
Logic error Division by zero pdns_recursor.cc selectWorker 2423 49 View Report
Logic error Division by zero sillyrecords.cc precsize_aton 48 32 View Report
Memory error Memory leak recursordist/rec-main.cc wipeCaches 2716 18 View Report

pdns/recpacketcache.cc
pdns/recursordist/test-syncres_cc1.cc
pdns/rpzloader.cc

index 926bf8003fa86526981b46ae79e40788117e4f0f..887ccb582448685a91b1e2fbade1ab00954befff 100644 (file)
@@ -178,24 +178,22 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash,
       iter->d_pbdata = std::move(*pbdata);
     }
 
-    break;
+    return;
   }
 
-  if (iter == range.second) { // nothing to refresh
-    struct Entry e(qname, std::move(responsePacket), std::move(query), tcp);
-    e.d_qhash = qhash;
-    e.d_type = qtype;
-    e.d_class = qclass;
-    e.d_ttd = now + ttl;
-    e.d_creation = now;
-    e.d_tag = tag;
-    e.d_vstate = valState;
-    if (pbdata) {
-      e.d_pbdata = std::move(*pbdata);
-    }
-
-    d_packetCache.insert(e);
+  struct Entry e(qname, std::move(responsePacket), std::move(query), tcp);
+  e.d_qhash = qhash;
+  e.d_type = qtype;
+  e.d_class = qclass;
+  e.d_ttd = now + ttl;
+  e.d_creation = now;
+  e.d_tag = tag;
+  e.d_vstate = valState;
+  if (pbdata) {
+    e.d_pbdata = std::move(*pbdata);
   }
+
+  d_packetCache.insert(e);
 }
 
 uint64_t RecursorPacketCache::size()
index 37f9e3227356ed33042b9c7b7b95e29b5f28d93d..c58550d9f499aa3c8e0d6a435fe47d43095c973e 100644 (file)
@@ -1571,7 +1571,7 @@ BOOST_AUTO_TEST_CASE(test_cname_loop)
 
   // Again to check cache
   try {
-    res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
+    sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
     BOOST_CHECK(false);
   }
   catch (const ImmediateServFailException& ex) {
@@ -1639,7 +1639,7 @@ BOOST_AUTO_TEST_CASE(test_cname_long_loop)
 
   // And again to check cache
   try {
-    res = sr->beginResolve(target1, QType(QType::A), QClass::IN, ret);
+    sr->beginResolve(target1, QType(QType::A), QClass::IN, ret);
     BOOST_CHECK(false);
   }
   catch (const ImmediateServFailException& ex) {
index 03d8228126289c00bdcc2239f258cdfb8c821b83..816be7892f6b9714655ac6aa29388e4ac5e5d9af 100644 (file)
@@ -339,7 +339,6 @@ static bool dumpZoneToDisk(const shared_ptr<Logr::Logger>& plogger, const DNSNam
          logger->error(Logr::Warning, err, "Unable to open file pointer"));
     return false;
   }
-  fd = -1;
 
   try {
     newZone->dump(fp.get());