]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
parsedate: detect more invalid dates better
authorDaniel Stenberg <daniel@haxx.se>
Tue, 21 Jun 2011 21:18:05 +0000 (23:18 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 23 Jun 2011 11:49:29 +0000 (13:49 +0200)
lib/parsedate.c
tests/data/test517
tests/libtest/lib517.c

index 6865f8e404f178b6c63ba5de0e8f93b5e505e64e..62f1a4181cd5c6d80187420a21458b6812c671f2 100644 (file)
@@ -485,6 +485,10 @@ static int parsedate(const char *date, time_t *output)
     return PARSEDATE_SOONER;
   }
 
+  if((mdaynum > 31) || (monnum > 11) ||
+     (hournum > 23) || (minnum > 59) || (secnum > 60))
+    return PARSEDATE_FAIL; /* clearly an illegal date */
+
   tm.tm_sec = secnum;
   tm.tm_min = minnum;
   tm.tm_hour = hournum;
index d7b91842c9d54dcf62892487999669ea6c9548ae..31b38b1a272d9b3a76e966900082117b2c73178d 100644 (file)
@@ -104,6 +104,11 @@ nothing
 75: Thu, 12-Aug-2007 20:61:99999999999 GMT => -1
 76: IAintNoDateFool => -1
 77: Thu Apr 18 22:50 2007 GMT => 1176936600
+78: 20110623 12:34:56 => 1308832496
+79: 20110632 12:34:56 => -1
+80: 20110623 56:34:56 => -1
+81: 20111323 12:34:56 => -1
+82: 20110623 12:34:79 => -1
 </stdout>
 
 # This test case previously testes an overflow case ("2094 Nov 6 =>
index 9e0a91f1666bc76a262dd53d9ef6a94abc33dbf0..8502e9521810815032fc25d21424732ddaf6d33b 100644 (file)
@@ -110,7 +110,11 @@ static const char *dates[]={
   "Thu, 12-Aug-2007 20:61:99999999999 GMT",
   "IAintNoDateFool",
   "Thu Apr 18 22:50 2007 GMT", /* without seconds */
-
+  "20110623 12:34:56",
+  "20110632 12:34:56",
+  "20110623 56:34:56",
+  "20111323 12:34:56",
+  "20110623 12:34:79",
   NULL
 };