Permalink
Browse files

improve error reporting on malformed labels

  • Loading branch information...
1 parent 62423be commit 0ffd51d5b94270f2bdd74a48cd7ba5d59915a5f6 @ahupowerdns ahupowerdns committed Aug 29, 2014
Showing with 3 additions and 2 deletions.
  1. +3 −1 pdns/dnsparser.cc
  2. +0 −1 pdns/pdns_recursor.cc
View
@@ -466,14 +466,16 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
ret.append(1,'.');
break;
}
- if((labellen & 0xc0) == 0xc0) {
+ else if((labellen & 0xc0) == 0xc0) {
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)
throw MOADNSException("forward reference during label decompression");
return getLabelFromContent(content, offset, ret, ++recurs);
}
+ else if(labellen > 63)
+ throw MOADNSException("Overly long label during label decompression ("+lexical_cast<string>((unsigned int)labellen)+")");
else {
// XXX FIXME THIS MIGHT BE VERY SLOW!
ret.reserve(ret.size() + labellen + 2);
@@ -894,7 +894,6 @@ string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fr
return 0;
}
-
if(MT->numProcesses() > g_maxMThreads) {
g_stats.overCapacityDrops++;
return 0;

0 comments on commit 0ffd51d

Please sign in to comment.