From: Remi Gacogne Date: Mon, 24 Dec 2018 13:26:13 +0000 (+0100) Subject: rec: Add constraints while loading the Public Suffix List X-Git-Tag: rec-4.2.0-alpha1~74^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=765ed1a254e04c3b6ab59e0cad9acb11a56e45e6;p=pdns rec: Add constraints while loading the Public Suffix List --- diff --git a/pdns/recursordist/pubsuffixloader.cc b/pdns/recursordist/pubsuffixloader.cc index 1bf1f5418..4f4655523 100644 --- a/pdns/recursordist/pubsuffixloader.cc +++ b/pdns/recursordist/pubsuffixloader.cc @@ -38,6 +38,7 @@ void initPublicSuffixList(const std::string& file) bool loaded = false; if (!file.empty()) { try { + Regex reg("^[.0-9a-z-]*$"); std::ifstream suffixFile(file); if (!suffixFile.is_open()) { throw std::runtime_error("Error opening the public suffix list file"); @@ -50,7 +51,14 @@ void initPublicSuffixList(const std::string& file) continue; } try { + line = toLower(line); + if (!reg.match(line)) { + continue; + } DNSName name(toLower(line)); + if (name.countLabels() < 2) { + continue; + } pbList.push_back(name.labelReverse().getRawLabels()); } catch(...) {