diff -up libical-1.0/src/libical/icaltime.c.old libical-1.0/src/libical/icaltime.c --- libical-1.0/src/libical/icaltime.c.old 2014-11-26 13:29:50.809112801 +0100 +++ libical-1.0/src/libical/icaltime.c 2014-11-26 14:14:42.309998754 +0100 @@ -77,7 +77,7 @@ * local daylight savings time applied to the result. * This function expects well-formed input. */ -static time_t make_time(struct tm *tm, int tzm) +static time_t make_time(struct tm *tm, int tzm, int be_strict) { time_t tim; @@ -85,7 +85,7 @@ static time_t make_time(struct tm *tm, i /* check that year specification within range */ - if (tm->tm_year < 70 || tm->tm_year > 138) + if (be_strict && sizeof (time_t) == 4 && (tm->tm_year < 70 || tm->tm_year > 138)) return((time_t) -1); /* check that month specification within range */ @@ -96,7 +96,7 @@ static time_t make_time(struct tm *tm, i /* check for upper bound of Jan 17, 2038 (to avoid possibility of 32-bit arithmetic overflow) */ - if (tm->tm_year == 138) { + if (be_strict && sizeof (time_t) == 4 && tm->tm_year == 138) { if (tm->tm_mon > 0) return((time_t) -1); else if (tm->tm_mday > 17) @@ -289,7 +289,7 @@ time_t icaltime_as_timet(const struct ic stm.tm_year = tt.year-1900; stm.tm_isdst = -1; - t = make_time(&stm, 0); + t = make_time(&stm, 0, 1); return t; @@ -395,7 +395,7 @@ time_t icaltime_as_timet_with_zone(const { icaltimezone *utc_zone; struct tm stm; - time_t t; + time_t t, maketimeval; char *old_tz; struct icaltimetype local_tt; @@ -427,6 +427,7 @@ time_t icaltime_as_timet_with_zone(const /* The functions putenv and mktime are not thread safe, inserting a lock to prevent any crashes */ + maketimeval = make_time (&stm, 0, 0); #ifdef HAVE_PTHREAD pthread_mutex_lock (&tzid_mutex); #endif @@ -442,6 +443,13 @@ to prevent any crashes */ #ifdef HAVE_PTHREAD pthread_mutex_unlock (&tzid_mutex); #endif + + if (t != maketimeval) { + fprintf (stderr, "Time %d doesn't match expected %d for %d-%d-%dT%02d%02d%02d\n", (int) maketimeval, (int) t, stm.tm_year + 1900, stm.tm_mon + 1, stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec); + fflush (stderr); + } + assert (t == maketimeval); + return t; }