]> granicus.if.org Git - pdns/commitdiff
DNSName("") == DNSName(".") == DNSName(string())
authorbert hubert <bert.hubert@netherlabs.nl>
Sat, 7 Nov 2015 21:16:13 +0000 (22:16 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 7 Nov 2015 21:16:13 +0000 (22:16 +0100)
pdns/dnsname.cc
pdns/test-dnsname_cc.cc

index ebc8598a3e1f6af0a294987062ff158650821f74..464eec5ce86c152ed10b38880aaaac574dc215e8 100644 (file)
@@ -20,7 +20,7 @@ std::ostream & operator<<(std::ostream &os, const DNSName& d)
 
 DNSName::DNSName(const char* p)
 {
-  if(p[0]=='.' && p[1]==0) {
+  if(p[0]==0 || (p[0]=='.' && p[1]==0)) {
     d_storage.assign(1, (char)0);
   } else {
     d_storage.reserve(strlen(p)+1);
index d21d36123d0277bf9711138559d0f370ecffb8d0..7758f28087935e85c21f363125f715403e4a0316 100644 (file)
@@ -100,6 +100,13 @@ BOOST_AUTO_TEST_CASE(test_basic) {
   { // empty() root
     DNSName name(".");
     BOOST_CHECK(!name.empty());
+    
+    DNSName rootnodot("");
+    BOOST_CHECK_EQUAL(name, rootnodot);
+    
+    string empty;
+    DNSName rootnodot2(empty);
+    BOOST_CHECK_EQUAL(rootnodot2, name);
   }
 
   DNSName left("ds9a.nl.");