]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Catch out_of_range exception when parsing serial
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 4 Aug 2016 17:00:07 +0000 (19:00 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 4 Aug 2016 17:00:07 +0000 (19:00 +0200)
pdns/dnsbackend.cc
pdns/zoneparser-tng.cc

index aa527bf0a5fc428a881fb37f1d7305df9e42cc03..a3f7225369b69c890f62a507efeed82154c5ac5a 100644 (file)
@@ -337,20 +337,25 @@ void fillSOAData(const string &content, SOAData &data)
   if(pleft>1) 
     data.hostmaster=DNSName(attodot(parts[1])); // ahu@ds9a.nl -> ahu.ds9a.nl, piet.puk@ds9a.nl -> piet\.puk.ds9a.nl
 
-  data.serial = pleft > 2 ? pdns_stou(parts[2]) : 0;
-  if (data.serial == UINT_MAX && errno == ERANGE) throw PDNSException("serial number too large in '"+parts[2]+"'");
+  try {
+    data.serial = pleft > 2 ? pdns_stou(parts[2]) : 0;
+    if (data.serial == UINT_MAX && errno == ERANGE) throw PDNSException("serial number too large in '"+parts[2]+"'");
 
-  data.refresh = pleft > 3 ? pdns_stou(parts[3])
-        : ::arg().asNum("soa-refresh-default");
+    data.refresh = pleft > 3 ? pdns_stou(parts[3])
+      : ::arg().asNum("soa-refresh-default");
 
-  data.retry = pleft > 4 ? pdns_stou(parts[4].c_str())
-        : ::arg().asNum("soa-retry-default");
+    data.retry = pleft > 4 ? pdns_stou(parts[4].c_str())
+      : ::arg().asNum("soa-retry-default");
 
-  data.expire = pleft > 5 ? pdns_stou(parts[5].c_str())
-        : ::arg().asNum("soa-expire-default");
+    data.expire = pleft > 5 ? pdns_stou(parts[5].c_str())
+      : ::arg().asNum("soa-expire-default");
 
-  data.default_ttl = pleft > 6 ? pdns_stou(parts[6].c_str())
-        : ::arg().asNum("soa-minimum-ttl");
+    data.default_ttl = pleft > 6 ? pdns_stou(parts[6].c_str())
+      : ::arg().asNum("soa-minimum-ttl");
+  }
+  catch(const std::out_of_range& oor) {
+    throw PDNSException("Out of range exception parsing "+content);
+  }
 }
 
 string serializeSOAData(const SOAData &d)
index c4f4becba4f7c13a79f38541e69853f315db608b..16afed667561d087190c2a3e177fb6d942e6813c 100644 (file)
@@ -102,7 +102,14 @@ unsigned int ZoneParserTNG::makeTTLFromZone(const string& str)
   if(str.empty())
     return 0;
 
-  unsigned int val=pdns_stou(str);
+  unsigned int val;
+  try {
+    val=pdns_stou(str);
+  }
+  catch (const std::out_of_range& oor) {
+    throw PDNSException("Unable to parse time specification '"+str+"' "+getLineOfFile());
+  }
+
   char lc=dns_tolower(str[str.length()-1]);
   if(!isdigit(lc))
     switch(lc) {