date.c: fix unsigned time_t comparison
authorMike Gorchak <mike.gorchak.qnx@gmail.com>
Mon, 25 Feb 2013 21:51:16 +0000 (23:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Feb 2013 22:23:43 +0000 (14:23 -0800)
tm_to_time_t() returns (time_t)-1 when it sees an error. On
platforms with unsigned time_t, this value will be larger than any
valid timestamp and will break the "Is this older than 10 days in
the future?" check.

Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
date.c
diff --git a/date.c b/date.c
index 57331ed406e2391e0a2bf327fbb86d3b62012324..1ac28e5e7bf0c1a63526c3bbaf212588a3ea2253 100644 (file)
--- a/date.c
+++ b/date.c
@@ -383,7 +383,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
                 * sense to specify timestamp way into the future.  Make
                 * sure it is not later than ten days from now...
                 */
-               if (now + 10*24*3600 < specified)
+               if ((specified != -1) && (now + 10*24*3600 < specified))
                        return 0;
                tm->tm_mon = r->tm_mon;
                tm->tm_mday = r->tm_mday;