]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: improve the handling of duplicate id's in bindbackend 8092/head
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 15 Jul 2019 08:55:28 +0000 (10:55 +0200)
committermind04 <mind04@monshouwer.org>
Wed, 17 Jul 2019 16:43:38 +0000 (18:43 +0200)
duplicate id's are not allowed in powerdns and will still result in undefined behavior

modules/bindbackend/bindbackend2.cc

index 4b60ad0d069d78c22f313f335ea84ee14f7bcba6..636a97af6eb6392a63cbb0abcaf6546da8e5ba3a 100644 (file)
@@ -1056,7 +1056,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
     g_log<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<qname<<"' within zoneID "<<zoneId<<endl;
 
   if (zoneId >= 0) {
-    if ((found = safeGetBBDomainInfo(zoneId, &bbd))) {
+    if ((found = (safeGetBBDomainInfo(zoneId, &bbd) && qname.isPartOf(bbd.d_name)))) {
       domain = bbd.d_name;
     }
   } else {
@@ -1068,7 +1068,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
 
   if(!found) {
     if(mustlog)
-      g_log<<Logger::Warning<<"Found no authoritative zone for "<<qname<<endl;
+      g_log<<Logger::Warning<<"Found no authoritative zone for '"<<qname<<"' and/or id "<<bbd.d_id<<endl;
     d_handle.d_list=false;
     return;
   }
@@ -1077,12 +1077,7 @@ void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, DNSPacket *p
     g_log<<Logger::Warning<<"Found a zone '"<<domain<<"' (with id " << bbd.d_id<<") that might contain data "<<endl;
 
   d_handle.id=bbd.d_id;
-
-  if(domain.empty())
-    d_handle.qname=qname;
-  else if(qname.isPartOf(domain))
-    d_handle.qname=qname.makeRelative(domain); // strip domain name
-
+  d_handle.qname=qname.makeRelative(domain); // strip domain name
   d_handle.qtype=qtype;
   d_handle.domain=domain;