From: Remi Gacogne Date: Mon, 12 Dec 2016 16:16:11 +0000 (+0100) Subject: SuffixMatchNode: Fix insertion issue for an existing node X-Git-Tag: rec-4.0.5-rc1~17^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=547d68ff19f082e7c986b34b04a6ea6ad605a62b;p=thirdparty%2Fpdns.git SuffixMatchNode: Fix insertion issue for an existing node If the node we are about to insert already existed as an intermediary one, we need to mark it as an end node. (cherry picked from commit ed221d0bc700158c21fcb8fc4463085713d07c53) --- diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index d6e6bb258f..e9adc82fb6 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -254,7 +254,12 @@ struct SuffixMatchNode endNode=true; } else if(labels.size()==1) { - children.insert(SuffixMatchNode(*labels.begin(), true)); + auto res=children.insert(SuffixMatchNode(*labels.begin(), true)); + if(!res.second) { + if(!res.first->endNode) { + res.first->endNode = true; + } + } } else { auto res=children.insert(SuffixMatchNode(*labels.rbegin(), false)); diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index 328e3a928d..0015972f7a 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -427,6 +427,13 @@ BOOST_AUTO_TEST_CASE(test_suffixmatch) { smn.add(DNSName(".")); // block the root BOOST_CHECK(smn.check(DNSName("a.root-servers.net."))); + + DNSName examplenet("example.net."); + DNSName net("net."); + smn.add(examplenet); + smn.add(net); + BOOST_CHECK(smn.check(examplenet)); + BOOST_CHECK(smn.check(net)); }