]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
turn a crash into right error - dnsname exception escaping
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 9 Jun 2015 14:25:50 +0000 (16:25 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 9 Jun 2015 14:25:50 +0000 (16:25 +0200)
pdns/dnsparser.cc

index fc04d9bf65db480d1168b43b6271c92bbcd321ef..0cece837810fba72c66b3276b769f36361657f7a 100644 (file)
@@ -406,10 +406,17 @@ string PacketReader::getLabel()
   vector<uint8_t> 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)