From: bert hubert Date: Sat, 24 Oct 2015 14:25:45 +0000 (+0200) Subject: massive speedup in dnsparser getName() which previously copied the entire packet... X-Git-Tag: dnsdist-1.0.0-alpha1~252^2~6^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25b991d4b737ef458471ebf8d4a5bfea901a2a4c;p=thirdparty%2Fpdns.git massive speedup in dnsparser getName() which previously copied the entire packet twice to fake a header we didn't use --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index b2b67b4f55..5b2b9faee7 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -413,15 +413,19 @@ uint8_t PacketReader::get8BitInt() DNSName PacketReader::getName() { unsigned int consumed; - vector content(d_content); - content.insert(content.begin(), sizeof(dnsheader), 0); - try { - DNSName dn((const char*) content.data(), content.size(), d_pos + sizeof(dnsheader), true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed); + DNSName dn((const char*) d_content.data() - 12, d_content.size() + 12, d_pos + sizeof(dnsheader), true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed); + // the -12 fakery is because we don't have the header in 'd_content', but we do need to get + // the internal offsets to work d_pos+=consumed; return dn; } + catch(std::range_error& re) + { + throw std::out_of_range(string("dnsname issue: ")+re.what()); + } + catch(...) { throw std::out_of_range("dnsname issue");