]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Perform stricter validation of timestamps. 16820/head
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 5 Feb 2026 08:21:41 +0000 (09:21 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 5 Feb 2026 08:21:41 +0000 (09:21 +0100)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/rcpgenerator.cc

index f3e930b8cdfe46b427e398edb02f3b0fa60ea5b2..ecc6c36db071083e244baf857fe2e929db34dd4e 100644 (file)
@@ -124,6 +124,13 @@ void RecordTextReader::xfrTime(uint32_t &val)
     throw RecordTextException("unable to parse '"+std::to_string(itmp)+"' into a valid time at position "+std::to_string(d_pos)+" in '"+d_string+"'");
   }
 
+  // Note tm_mon is still in 1..12 range at this point
+  if (tm.tm_sec < 0 || tm.tm_sec > 60 || tm.tm_min < 0 || tm.tm_min > 59 ||
+      tm.tm_hour < 0 || tm.tm_hour > 23 || tm.tm_mday < 0 || tm.tm_mday > 31 ||
+      tm.tm_mon < 1 || tm.tm_mon > 12) {
+    throw RecordTextException("invalid time specification '"+std::to_string(itmp)+"' at position "+std::to_string(d_pos)+" in '"+d_string+"'");
+  }
+
   tm.tm_year-=1900;
   tm.tm_mon-=1;
   // coverity[store_truncates_time_t]