Changeset 2214

Show
Ignore:
Timestamp:
06/09/11 23:18:10 (2 years ago)
Author:
ahu
Message:

Christoph Meerwald discovered we do not parse EDNS options on TSIG-signed questions, since we expect the OPT record to be the last one.

Files:
1 modified

Legend:

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

    r2161 r2214  
    1919#include "utility.hh" 
    2020#include "dnsrecords.hh" 
     21#include <boost/foreach.hpp> 
    2122 
    2223boilerplate_conv(A, ns_t_a, conv.xfrIP(d_ip)); 
     
    299300                 ) 
    300301 
     302 
     303 
    301304bool getEDNSOpts(const MOADNSParser& mdp, EDNSOpts* eo) 
    302305{ 
    303   if(mdp.d_header.arcount && !mdp.d_answers.empty() &&  
    304      mdp.d_answers.back().first.d_type == QType::OPT) { 
    305     eo->d_packetsize=mdp.d_answers.back().first.d_class; 
    306      
    307     EDNS0Record stuff; 
    308     uint32_t ttl=ntohl(mdp.d_answers.back().first.d_ttl); 
    309     memcpy(&stuff, &ttl, sizeof(stuff)); 
    310  
    311     eo->d_extRCode=stuff.extRCode; 
    312     eo->d_version=stuff.version; 
    313     eo->d_Z = ntohs(stuff.Z); 
    314     OPTRecordContent* orc =  
    315       dynamic_cast<OPTRecordContent*>(mdp.d_answers.back().first.d_content.get()); 
    316     if(!orc) 
    317       return false; 
    318     orc->getData(eo->d_options); 
    319  
    320     return true; 
    321   } 
    322   else 
    323     return false; 
     306  if(mdp.d_header.arcount && !mdp.d_answers.empty()) { 
     307    BOOST_FOREACH(const MOADNSParser::answers_t::value_type& val, mdp.d_answers) { 
     308      if(val.first.d_place == DNSRecord::Additional && val.first.d_type == QType::OPT) { 
     309        eo->d_packetsize=val.first.d_class; 
     310        
     311        EDNS0Record stuff; 
     312        uint32_t ttl=ntohl(val.first.d_ttl); 
     313        memcpy(&stuff, &ttl, sizeof(stuff)); 
     314         
     315        eo->d_extRCode=stuff.extRCode; 
     316        eo->d_version=stuff.version; 
     317        eo->d_Z = ntohs(stuff.Z); 
     318        OPTRecordContent* orc =  
     319          dynamic_cast<OPTRecordContent*>(val.first.d_content.get()); 
     320        if(!orc) 
     321          return false; 
     322        orc->getData(eo->d_options); 
     323        return true; 
     324      } 
     325    } 
     326  } 
     327  return false; 
    324328} 
    325329