]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
fix forward reference-check in getLabelFromContent()
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 13 Apr 2015 11:52:42 +0000 (13:52 +0200)
committermind04 <mind04@monshouwer.org>
Mon, 13 Apr 2015 11:52:42 +0000 (13:52 +0200)
pdns/dnsparser.cc

index 77105d10bf14cf2f84f6fd7478fb7b0cb44cc102..f6fc711566928d0f32f330b3a6a29e8756b9be9d 100644 (file)
@@ -462,6 +462,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
   if(recurs > 1000) // the forward reference-check below should make this test 100% obsolete
     throw MOADNSException("Loop");
   // it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop
+  int pos = frompos;
   for(;;) {
     unsigned char labellen=content.at(frompos++);
 
@@ -474,7 +475,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
       uint16_t offset=256*(labellen & ~0xc0) + (unsigned int)content.at(frompos++) - sizeof(dnsheader);
       //        cout<<"This is an offset, need to go to: "<<offset<<endl;
 
-      if(offset >= frompos-2)
+      if(offset >= pos-2)
         throw MOADNSException("forward reference during label decompression");
       return getLabelFromContent(content, offset, ret, ++recurs);
     }