]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
More uses cases for lookupEnd(). 15450/head
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 4 Aug 2025 13:42:19 +0000 (15:42 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 4 Aug 2025 13:45:38 +0000 (15:45 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/auth-secondarycommunicator.cc
pdns/dnsbackend.cc
pdns/rfc2136handler.cc
pdns/ueberbackend.cc
pdns/ws-auth.cc

index 1e1815f495b4867d146ec7c5618d5a7f45768e64..24b8321f7b4c0ab22774018454d874cb80cc6a5b 100644 (file)
@@ -1319,8 +1319,7 @@ void CommunicatorClass::secondaryRefresh(PacketHandler* P)
       hasSOA = B->get(zr);
       if (hasSOA) {
         fillSOAData(zr, sd);
-        while (B->get(zr))
-          ;
+        B->lookupEnd();
       }
     }
     catch (...) {
index 2edbde4ee9a594311b5518a6a431c0649393ff19..8d46a6f28e25dfe0fb4ce2aa43386022e549cedc 100644 (file)
@@ -93,7 +93,9 @@ bool DNSBackend::searchRecords(const string& pattern, size_t maxResults, vector<
     DNSResourceRecord rec;
     while (get(rec)) {
       if (maxResults == 0) {
-        continue;
+        // No need to look any further
+        lookupEnd();
+        break;
       }
       if (simpleMatch.match(rec.qname) || simpleMatch.match(rec.content)) {
         result.emplace_back(rec);
@@ -315,9 +317,7 @@ bool DNSBackend::getSOA(const ZoneName& domain, domainid_t zoneId, SOAData& soaD
     }
   }
   catch (...) {
-    while (this->get(resourceRecord)) {
-      ;
-    }
+    this->lookupEnd();
     throw;
   }
 
index 80e896d4c8119f591563a7da0bf509227cb32cbb..4dcd444fa9d2bfddc10e63a74fe55aa36169d1fe 100644 (file)
@@ -41,8 +41,11 @@ int PacketHandler::checkUpdatePrerequisites(const DNSRecord *rr, DomainInfo *di)
   while(di->backend->get(rec)) {
     if (!rec.qtype.getCode())
       continue;
-    if ((rr->d_type != QType::ANY && rec.qtype == rr->d_type) || rr->d_type == QType::ANY)
+    if ((rr->d_type != QType::ANY && rec.qtype == rr->d_type) || rr->d_type == QType::ANY) {
       foundRecord=true;
+      di->backend->lookupEnd();
+      break;
+    }
   }
 
   // Section 3.2.1
@@ -952,8 +955,7 @@ int PacketHandler::processUpdate(DNSPacket& packet) { // NOLINT(readability-func
       while (di.backend->get(rec)) {
         if (rec.qtype != QType::CNAME && rec.qtype != QType::ENT && rec.qtype != QType::RRSIG) {
           // leave database handle in a consistent state
-          while (di.backend->get(rec))
-            ;
+          di.backend->lookupEnd();
           g_log<<Logger::Warning<<msgPrefix<<"Refusing update for " << rr->d_name << "/" << QType(rr->d_type).toString() << ": Data other than CNAME exists for the same name"<<endl;
           di.backend->abortTransaction();
           return RCode::Refused;
@@ -967,8 +969,7 @@ int PacketHandler::processUpdate(DNSPacket& packet) { // NOLINT(readability-func
       while (di.backend->get(rec)) {
         if (rec.qtype == QType::CNAME && rr->d_type != QType::RRSIG) {
           // leave database handle in a consistent state
-          while (di.backend->get(rec))
-            ;
+          di.backend->lookupEnd();
           g_log<<Logger::Warning<<msgPrefix<<"Refusing update for " << rr->d_name << "/" << QType(rr->d_type).toString() << ": CNAME exists for the same name"<<endl;
           di.backend->abortTransaction();
           return RCode::Refused;
index 7a835c8b11ee8f910fc6eabeb509eeb2c25ea32c..064219410f71d529ae52cd814cd6eda806aecc84 100644 (file)
@@ -427,11 +427,7 @@ bool UeberBackend::fillSOAFromZoneRecord(ZoneName& shorter, const domainid_t zon
   }
   catch (...) {
     g_log << Logger::Warning << "Backend returned a broken SOA for zone '" << shorter.toLogString() << "'" << endl;
-
-    while (get(zoneRecord)) {
-      ;
-    }
-
+    lookupEnd();
     return false;
   }
 
index 47ac61eecd1c5139c6b61c021a76f75442e828da..d9644fcfa1421c145d07b03f0d258baed3f9230d 100644 (file)
@@ -2448,9 +2448,7 @@ static void patchZone(UeberBackend& backend, const ZoneName& zonename, DomainInf
                     || exclusiveEntryTypes.count(resourceRecord.qtype.getCode()) != 0)) {
 
               // leave database handle in a consistent state
-              while (domainInfo.backend->get(resourceRecord)) {
-                ;
-              }
+              domainInfo.backend->lookupEnd();
 
               throw ApiException("RRset " + qname.toString() + " IN " + qtype.toString() + ": Conflicts with pre-existing RRset");
             }