From: Otto Moerbeek Date: Fri, 25 Mar 2022 10:17:44 +0000 (+0100) Subject: Scanbuid fixes X-Git-Tag: rec-4.7.0-beta1~31^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46839608fd33a5cba40080d28e7fa00e824a4f65;p=thirdparty%2Fpdns.git Scanbuid fixes 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 --- diff --git a/pdns/recpacketcache.cc b/pdns/recpacketcache.cc index 926bf8003f..887ccb5824 100644 --- a/pdns/recpacketcache.cc +++ b/pdns/recpacketcache.cc @@ -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() diff --git a/pdns/recursordist/test-syncres_cc1.cc b/pdns/recursordist/test-syncres_cc1.cc index 37f9e32273..c58550d9f4 100644 --- a/pdns/recursordist/test-syncres_cc1.cc +++ b/pdns/recursordist/test-syncres_cc1.cc @@ -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) { diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index 03d8228126..816be7892f 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -339,7 +339,6 @@ static bool dumpZoneToDisk(const shared_ptr& plogger, const DNSNam logger->error(Logr::Warning, err, "Unable to open file pointer")); return false; } - fd = -1; try { newZone->dump(fp.get());