From: bert hubert Date: Sat, 7 Nov 2015 21:16:13 +0000 (+0100) Subject: DNSName("") == DNSName(".") == DNSName(string()) X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c7983ed650619ddcc61ec0dad00de00434053cf;p=pdns DNSName("") == DNSName(".") == DNSName(string()) --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index ebc8598a3..464eec5ce 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -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); diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index d21d36123..7758f2808 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -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.");