Changeset 1147

Show
Ignore:
Timestamp:
03/01/08 23:11:26 (7 years ago)
Author:
ahu
Message:

fix cname-and-wildcard with qname but no rrcode match, reported by zzyzz

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/packethandler.cc

    r1113 r1147  
    1  /* 
     1/* 
    22    PowerDNS Versatile Database Driven Nameserver 
    3     Copyright (C) 2002-2007  PowerDNS.COM BV 
     3    Copyright (C) 2002-2008  PowerDNS.COM BV 
    44 
    55    This program is free software; you can redistribute it and/or modify 
     
    3434#include "dnsproxy.hh" 
    3535 
     36 
    3637extern StatBag S; 
    3738extern PacketCache PC;   
     
    264265  string subdomain=target; 
    265266  string::size_type pos; 
     267 
    266268  while((pos=subdomain.find("."))!=string::npos) { 
    267269    subdomain=subdomain.substr(pos+1); 
     
    305307    } 
    306308    if(found) { 
    307       DLOG(L<<"Wildcard match on '"<<string("*.")+subdomain<<"'"<<endl); 
     309      DLOG(L<<"Wildcard match on '"<<string("*.")+subdomain<<"'"<<", retargeted="<<retargeted<<endl); 
    308310      return retargeted ? 2 : 1; 
    309311    } 
    310312  } 
     313  DLOG(L<<"Returning no hit for '"<<string("*.")+subdomain<<"'"<<endl); 
    311314  return 0; 
    312315} 
     
    385388    bool shortcut=p->qtype.getCode()!=QType::SOA && p->qtype.getCode()!=QType::ANY; 
    386389    int hits=0; 
     390    bool relevantNS=false; 
    387391 
    388392    while(B.get(rr)) { 
     393      if(rr.qtype.getCode() == QType::NS && p->qtype.getCode() != QType::NS) { // possible retargeting 
     394        relevantNS=true; 
     395      } 
    389396      if(rr.qtype.getCode()!=QType::NS || p->qtype.getCode()==QType::NS) 
    390397        hits++; 
     
    399406      } 
    400407    } 
    401     if(hits && !found && !rfound && shortcut ) { // we found matching qnames but not a qtype 
     408    if(hits && !relevantNS && !found && !rfound && shortcut ) { // we found matching qnames but not a qtype 
    402409      DLOG(L<<"Found matching qname, but not the qtype"<<endl); 
    403410      return 2; 
     
    681688        rr.d_place=DNSResourceRecord::AUTHORITY; 
    682689        r->addRecord(rr); 
     690        if(mret == 2) 
     691          goto sendit; 
    683692      } 
    684693    }