]> granicus.if.org Git - pdns/commitdiff
rec: Add constraints while loading the Public Suffix List
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Dec 2018 13:26:13 +0000 (14:26 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Dec 2018 13:26:13 +0000 (14:26 +0100)
pdns/recursordist/pubsuffixloader.cc

index 1bf1f5418382aaac66f9cec5f5d0c2156e4a8a98..4f465552333621fdf0ddaf1a952d9aa066b12190 100644 (file)
@@ -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(...) {