]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Validate names with address records to be valid hostnames in pdnsutil check-zone 3913/head
authorHåkan Lindqvist <h@qw.se>
Sat, 28 May 2016 17:17:57 +0000 (19:17 +0200)
committerHåkan Lindqvist <h@qw.se>
Sat, 28 May 2016 17:31:07 +0000 (19:31 +0200)
pdns/pdnsutil.cc

index 1283930d54730b00b4004fb3ddcd8adb9f6a533a..0136acede5c9c048ea939c42bf92669a05031ef0 100644 (file)
@@ -564,6 +564,17 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vect
       }
     }
 
+    if(rr.qtype.getCode() == QType::A || rr.qtype.getCode() == QType::AAAA)
+    {
+      Regex hostnameRegex=Regex("^(([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)\\.)+$");
+      if (!hostnameRegex.match(rr.qname.toString()))
+      {
+        cout<<"[Error] A or AAAA record found at '"<<rr.qname.toString()<<"'. This name is not a valid hostname."<<endl;
+        numerrors++;
+        continue;
+      }
+    }
+
     if (rr.qtype.getCode() == QType::CNAME) {
       if (!cnames.count(rr.qname))
         cnames.insert(rr.qname);