]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec-4.3.x: Avoid a CNAME loop detection issue with DNS64 9702/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 10 Nov 2020 17:05:15 +0000 (18:05 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 10 Nov 2020 17:05:15 +0000 (18:05 +0100)
When the requested qname is a CNAME to a second CNAME, the CNAME
loop detection might get incorrectly triggered because the CNAMEs
were already present in the vector of result records.

pdns/lua-recursor4.cc

index 36239b0e14a779b788e7bbd0b6c19cab3fcef7be..f5f43519173ed9884615d010a7b49a02741f1492 100644 (file)
@@ -36,7 +36,16 @@ RecursorLua4::RecursorLua4() { prepareContext(); }
 
 static int getFakeAAAARecords(const DNSName& qname, const std::string& prefix, vector<DNSRecord>& ret)
 {
-  int rcode=directResolve(qname, QType(QType::A), 1, ret);
+  /* we pass a separate vector of records because we will be resolving the initial qname
+     again, possibly encountering the same CNAME(s), and we don't want to trigger the CNAME
+     loop detection. */
+  std::vector<DNSRecord> newRecords;
+  int rcode=directResolve(qname, QType(QType::A), 1, newRecords);
+
+  ret.reserve(ret.size() + newRecords.size());
+  for (auto& record : newRecords) {
+    ret.push_back(std::move(record));
+  }
 
   ComboAddress prefixAddress(prefix);