aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-06-21 23:18:05 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-06-23 13:49:29 +0200
commit57d51be60c0bb299a30ae5b4c66d9a7113e7586b (patch)
tree9b16c665f94f51cf56d519972c3796d68f292f66
parent8da5da9b6544337b8a675db092da201f279265d4 (diff)
parsedate: detect more invalid dates better
-rw-r--r--lib/parsedate.c4
-rw-r--r--tests/data/test5175
-rw-r--r--tests/libtest/lib517.c6
3 files changed, 14 insertions, 1 deletions
diff --git a/lib/parsedate.c b/lib/parsedate.c
index 6865f8e40..62f1a4181 100644
--- a/lib/parsedate.c
+++ b/lib/parsedate.c
@@ -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;
diff --git a/tests/data/test517 b/tests/data/test517
index d7b91842c..31b38b1a2 100644
--- a/tests/data/test517
+++ b/tests/data/test517
@@ -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 =>
diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c
index 9e0a91f16..8502e9521 100644
--- a/tests/libtest/lib517.c
+++ b/tests/libtest/lib517.c
@@ -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
};