]> granicus.if.org Git - pdns/commitdiff
test parsing the root from packets, fix that we failed on that
authorbert hubert <bert.hubert@powerdns.com>
Thu, 5 Nov 2015 15:13:50 +0000 (16:13 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Thu, 5 Nov 2015 15:13:50 +0000 (16:13 +0100)
pdns/dnsname.cc
pdns/test-dnsname_cc.cc

index 8388391d47a4d90b584d09f35601a6a74e6660a1..4d17129f7c783877b9586e8c9e12a094a4046c30 100644 (file)
@@ -66,6 +66,8 @@ void DNSName::packetParser(const char* pos, int len, int offset, bool uncompress
       throw std::range_error("Found an invalid label length in qname");
     pos+=labellen;
   }
+  if(d_storage.empty())
+    d_storage.append(1, (char)0); // we just parsed the root
   if(consumed)
     *consumed = pos - opos - offset;
   if(qtype && pos + labellen + 2 <= end)
index f102b45a26030a813913db7257c5cfaae648fd76..c0b12f5e95a1660a4661574f1d8d4919a093e1ca 100644 (file)
@@ -230,6 +230,16 @@ BOOST_AUTO_TEST_CASE(test_Append) {
   BOOST_CHECK(dn == DNSName("www.powerdns.com."));
 }
 
+BOOST_AUTO_TEST_CASE(test_PacketParse) {
+  vector<unsigned char> packet;
+  reportBasicTypes();
+  DNSName root(".");
+  DNSPacketWriter dpw1(packet, DNSName("."), QType::AAAA);
+  DNSName p((char*)&packet[0], packet.size(), 12, false);
+  BOOST_CHECK_EQUAL(p, root);
+}
+
+
 BOOST_AUTO_TEST_CASE(test_QuestionHash) {
   vector<unsigned char> packet;
   reportBasicTypes();