]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Correctly handle QType::ANY in replaceRRSet().
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 18 Jun 2025 09:47:30 +0000 (11:47 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Wed, 18 Jun 2025 10:50:25 +0000 (12:50 +0200)
Co-Authored-By: HÃ¥kan Lindqvist <h@qw.se>
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
modules/lmdbbackend/lmdbbackend.cc

index 3e17a7f9bbfa9c66ab8ad9b612db4ce53712e303..151669dfd94c6123f02069051196c2045c176cbb 100644 (file)
@@ -1303,12 +1303,26 @@ bool LMDBBackend::replaceRRSet(domainid_t domain_id, const DNSName& qname, const
     return false;
   }
 
+  DNSName relative = qname.makeRelative(di.zone);
   compoundOrdername co;
-  auto cursor = txn->txn->getCursor(txn->db->dbi);
-  MDBOutVal key, val;
-  string match = co(domain_id, qname.makeRelative(di.zone), qt.getCode());
-  if (!cursor.find(match, key, val)) {
-    cursor.del();
+  string match;
+  if (qt.getCode() == QType::ANY) {
+    match = co(domain_id, relative);
+    deleteDomainRecords(*txn, QType::ANY, match);
+    // Update key if insertions are to follow
+    if (!rrset.empty()) {
+      match = co(domain_id, relative, rrset.front().qtype.getCode());
+    }
+  }
+  else {
+    auto cursor = txn->txn->getCursor(txn->db->dbi);
+    MDBOutVal key{};
+    MDBOutVal val{};
+    match = co(domain_id, relative, qt.getCode());
+    // There should be at most one exact match here.
+    if (cursor.find(match, key, val) == 0) {
+      cursor.del();
+    }
   }
 
   if (!rrset.empty()) {