DNSName DNSName::getCommonLabels(const DNSName& other) const
{
- DNSName result;
+ if (empty() || other.empty()) {
+ return DNSName();
+ }
+
+ DNSName result(g_rootdnsname);
const std::vector<std::string> ours = getRawLabels();
const std::vector<std::string> others = other.getRawLabels();
signQName = pos->dr.d_name.makeLowerCase();
if (pos->dr.d_type == QType::NSEC) {
authQName = signQName.getCommonLabels(getRR<NSECRecordContent>(pos->dr)->d_next);
- if (authQName.empty()) {
- authQName = g_rootdnsname;
- }
}
else {
authQName = signQName;
BOOST_CHECK_EQUAL(name2.getCommonLabels(name1), DNSName("powerdns.com"));
const DNSName name3("www.powerdns.org");
- BOOST_CHECK_EQUAL(name1.getCommonLabels(name3), DNSName());
- BOOST_CHECK_EQUAL(name2.getCommonLabels(name3), DNSName());
- BOOST_CHECK_EQUAL(name3.getCommonLabels(name1), DNSName());
- BOOST_CHECK_EQUAL(name3.getCommonLabels(name2), DNSName());
+ BOOST_CHECK_EQUAL(name1.getCommonLabels(name3), g_rootdnsname);
+ BOOST_CHECK_EQUAL(name2.getCommonLabels(name3), g_rootdnsname);
+ BOOST_CHECK_EQUAL(name3.getCommonLabels(name1), g_rootdnsname);
+ BOOST_CHECK_EQUAL(name3.getCommonLabels(name2), g_rootdnsname);
const DNSName name4("WWw.PowErDnS.org");
BOOST_CHECK_EQUAL(name3.getCommonLabels(name4), name3);
BOOST_CHECK_EQUAL(name4.getCommonLabels(name3), name4);
+
+ const DNSName(name5);
+ BOOST_CHECK_EQUAL(name1.getCommonLabels(name5), DNSName());
+ BOOST_CHECK_EQUAL(name5.getCommonLabels(name1), DNSName());
}
BOOST_AUTO_TEST_SUITE_END()