From: Miod Vallat Date: Wed, 18 Jun 2025 09:47:30 +0000 (+0200) Subject: Correctly handle QType::ANY in replaceRRSet(). X-Git-Tag: dnsdist-2.0.0-beta1~2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db20ffc15386ec371e74b0c2615b9b2621cd0011;p=thirdparty%2Fpdns.git Correctly handle QType::ANY in replaceRRSet(). Co-Authored-By: HÃ¥kan Lindqvist Signed-off-by: Miod Vallat --- diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 3e17a7f9bb..151669dfd9 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -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()) {