Show
Ignore:
Timestamp:
04/22/06 17:30:35 (4 years ago)
Author:
ahu
Message:

fix david g's bug one level up as well - we used to do the wrong thing with truncated packets, leaving untrue an, ns and arcounts around
change version to 3.0.1-snapshot

Files:
1 modified

Legend:

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

    r760 r761  
    189189  copy(packet+sizeof(dnsheader), packet+len, d_content.begin()); 
    190190   
    191   unsigned int n; 
     191  unsigned int n=0; 
    192192 
    193193  PacketReader pr(d_content); 
     
    235235  } 
    236236  catch(out_of_range &re) { 
    237     if(!(validPacket && d_header.tc)) // don't sweat it over truncated packets 
     237    if(validPacket && d_header.tc) { // don't sweat it over truncated packets, but do adjust an, ns and arcount 
     238      if(n < d_header.ancount) { 
     239        d_header.ancount=n; d_header.nscount = d_header.arcount = 0; 
     240      } 
     241      else if(n < d_header.ancount + d_header.nscount) { 
     242        d_header.nscount = n - d_header.ancount; d_header.arcount=0; 
     243      } 
     244      else { 
     245        d_header.arcount = n - d_header.ancount - d_header.nscount; 
     246      } 
     247    } 
     248    else { 
    238249      throw MOADNSException("Error parsing packet of "+lexical_cast<string>(len)+" bytes (rd="+ 
    239250                            lexical_cast<string>(d_header.rd)+ 
    240251                            "), out of bounds: "+string(re.what())); 
     252    } 
    241253  } 
    242254}