From 5678437b582116fda9ff9d933fbcd21e09d8106a Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Tue, 26 Jul 2016 13:48:01 +0200 Subject: [PATCH] RPZ: filter correctly by name Closes #4086 --- pdns/filterpo.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pdns/filterpo.cc b/pdns/filterpo.cc index d2434d2f6..55037f85b 100644 --- a/pdns/filterpo.cc +++ b/pdns/filterpo.cc @@ -32,30 +32,30 @@ bool findNamedPolicy(const map& polmap, const { DNSName s(qname); - /* for www.powerdns.com, we need to check: - www.powerdns.com. - *.powerdns.com. - powerdns.com. - *.com. - com. - *. - . */ + /* for www.powerdns.com, we need to check: + www.powerdns.com. + *.powerdns.com. + *.com. + *. + */ bool first=true; + map::const_iterator iter; do { - auto iter = polmap.find(s); - if(iter != polmap.end()) { - pol=iter->second; - return true; - } - if(!first) { - iter = polmap.find(DNSName("*")+s); + if(first) { + iter = polmap.find(s); if(iter != polmap.end()) { - pol=iter->second; - return true; + pol=iter->second; + return true; } } first=false; + + iter = polmap.find(DNSName("*")+s); + if(iter != polmap.end()) { + pol=iter->second; + return true; + } } while(s.chopOff()); return false; } -- 2.40.0