]> granicus.if.org Git - pdns/commitdiff
fix crash on malformed EDNS0 packet (thanks David G)
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 22 Apr 2006 13:57:30 +0000 (13:57 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 22 Apr 2006 13:57:30 +0000 (13:57 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@760 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnsparser.cc

index d69c973e47196f40196540719cc1fe50153f1095..17a122289c50728ac370c4c9ef06fbcc765f3576 100644 (file)
@@ -243,13 +243,13 @@ void MOADNSParser::init(const char *packet, unsigned int len)
 
 bool MOADNSParser::getEDNSOpts(EDNSOpts* eo)
 {
-  if(d_header.arcount) {
+  if(d_header.arcount && !d_answers.empty()) {
     eo->d_packetsize=d_answers.back().first.d_class;
     struct Stuff {
       uint8_t extRCode, version;
       uint16_t Z;
     } __attribute__((packed));
-    
+     
     Stuff stuff;
     uint32_t ttl=ntohl(d_answers.back().first.d_ttl);
     memcpy(&stuff, &ttl, sizeof(stuff));