From 6c7983ed650619ddcc61ec0dad00de00434053cf Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 7 Nov 2015 22:16:13 +0100 Subject: [PATCH] DNSName("") == DNSName(".") == DNSName(string()) --- pdns/dnsname.cc | 2 +- pdns/test-dnsname_cc.cc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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."); -- 2.40.0