From: bert hubert Date: Tue, 9 Jun 2015 14:25:50 +0000 (+0200) Subject: turn a crash into right error - dnsname exception escaping X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~28^2~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c122953150f775103dd6b1302f70ab710b50af75;p=thirdparty%2Fpdns.git turn a crash into right error - dnsname exception escaping --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index fc04d9bf65..0cece83781 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -406,10 +406,17 @@ string PacketReader::getLabel() vector content(d_content); content.insert(content.begin(), sizeof(dnsheader), 0); - string ret = DNSName((const char*) content.data(), content.size(), d_pos + sizeof(dnsheader), true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed).toString(); + try { + string ret = DNSName((const char*) content.data(), content.size(), d_pos + sizeof(dnsheader), true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed).toString(); + + d_pos+=consumed; + return ret; + } + catch(...) + { + throw std::out_of_range("dnsname issue"); + } - d_pos+=consumed; - return ret; } static string txtEscape(const string &name)