From: Bert Hubert Date: Sat, 1 Mar 2008 22:11:26 +0000 (+0000) Subject: fix cname-and-wildcard with qname but no rrcode match, reported by zzyzz X-Git-Tag: rec-3.1.7.1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcf21dff3cd44fed34ec18baaf54ff2560453642;p=thirdparty%2Fpdns.git fix cname-and-wildcard with qname but no rrcode match, reported by zzyzz git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1147 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index a5fc730fd9..6ba69a92b0 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -1,6 +1,6 @@ - /* +/* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2002-2007 PowerDNS.COM BV + Copyright (C) 2002-2008 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as @@ -33,6 +33,7 @@ #include "communicator.hh" #include "dnsproxy.hh" + extern StatBag S; extern PacketCache PC; extern CommunicatorClass Communicator; @@ -263,6 +264,7 @@ int PacketHandler::doWildcardRecords(DNSPacket *p, DNSPacket *r, string &target) string subdomain=target; string::size_type pos; + while((pos=subdomain.find("."))!=string::npos) { subdomain=subdomain.substr(pos+1); // DLOG(); @@ -304,10 +306,11 @@ int PacketHandler::doWildcardRecords(DNSPacket *p, DNSPacket *r, string &target) } } if(found) { - DLOG(L<<"Wildcard match on '"<qtype.getCode()!=QType::SOA && p->qtype.getCode()!=QType::ANY; int hits=0; + bool relevantNS=false; while(B.get(rr)) { + if(rr.qtype.getCode() == QType::NS && p->qtype.getCode() != QType::NS) { // possible retargeting + relevantNS=true; + } if(rr.qtype.getCode()!=QType::NS || p->qtype.getCode()==QType::NS) hits++; if(!rfound && rr.qtype.getCode()==QType::CNAME) { @@ -398,7 +405,7 @@ int PacketHandler::makeCanonic(DNSPacket *p, DNSPacket *r, string &target) r->addRecord(rr); } } - if(hits && !found && !rfound && shortcut ) { // we found matching qnames but not a qtype + if(hits && !relevantNS && !found && !rfound && shortcut ) { // we found matching qnames but not a qtype DLOG(L<<"Found matching qname, but not the qtype"<addRecord(rr); + if(mret == 2) + goto sendit; } }