]> granicus.if.org Git - pdns/commitdiff
many thanks to David GAVARRET
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 10 Nov 2006 17:04:38 +0000 (17:04 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 10 Nov 2006 17:04:38 +0000 (17:04 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@919 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/syncres.cc

index 79d749feb8030157b5c12a08128113b61a19c6cc..672a8d35a180b1d0325bda0e79f0a7d5406a4899 100644 (file)
@@ -16,6 +16,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+#include <boost/algorithm/string.hpp>
 #include "utility.hh"
 #include "syncres.hh"
 #include <iostream>
@@ -855,9 +856,18 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
        return RCode::NXDomain;
       }
       if(!newtarget.empty()) {
+       if(iequals(newtarget,qname)) {
+         LOG<<prefix<<qname<<": status=got a CNAME referral to self, returning SERVFAIL"<<endl;
+         return RCode::ServFail;
+       }
+       if(depth > 10) {
+         LOG<<prefix<<qname<<": status=got a CNAME referral, but recursing too deep, returning SERVFAIL"<<endl;
+         return RCode::ServFail;
+       }
        LOG<<prefix<<qname<<": status=got a CNAME referral, starting over with "<<newtarget<<endl;
+
        set<GetBestNSAnswer>beenthere2;
-       return doResolve(newtarget, qtype, ret,0,beenthere2);
+       return doResolve(newtarget, qtype, ret, depth + 1, beenthere2);
       }
       if(nsset.empty() && !d_lwr.d_rcode) {
        LOG<<prefix<<qname<<": status=noerror, other types may exist, but we are done "<<(negindic ? "(have negative SOA)" : "")<<endl;