diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libical/icaltime.c | 10 | ||||
-rw-r--r-- | src/libical/icaltime.h | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libical/icaltime.c b/src/libical/icaltime.c index fe03aee5..b8b0f11b 100644 --- a/src/libical/icaltime.c +++ b/src/libical/icaltime.c @@ -120,10 +120,13 @@ static time_t make_time(struct tm *tm, int tzm) if (tm->tm_mon < 0 || tm->tm_mon > 11) return ((time_t) - 1); + if (tm->tm_year < 2) + return ((time_t)-1); + #if (SIZEOF_TIME_T == 4) /* check that year specification within range */ - if (tm->tm_year < 70 || tm->tm_year > 138) + if (tm->tm_year > 138) return ((time_t) - 1); /* check for upper bound of Jan 17, 2038 (to avoid possibility of @@ -136,6 +139,11 @@ static time_t make_time(struct tm *tm, int tzm) return ((time_t) - 1); } } +#else + /* We don't support years >= 10000, because the function has not been tested at this range. */ + if (tm->tm_year >= 8100) { + return ((time_t)-1); + } #endif /* SIZEOF_TIME_T */ /* diff --git a/src/libical/icaltime.h b/src/libical/icaltime.h index 816eac6f..2de53c9f 100644 --- a/src/libical/icaltime.h +++ b/src/libical/icaltime.h @@ -199,7 +199,8 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_day_of_year(const int doy, * only pass an icaltime in UTC, since no conversion is done. Even in that case, * it's probably better to just use icaltime_as_timet_with_zone(). * - * The return value is defined for dates starting with 1902-01-01 until 10000-01-01 (excl.). + * The return value is defined for dates ranging from 1902-01-01 (incl.) up to 10000-01-01 (excl.) + * if time_t has a size of 64 bit and up to 2038-01-18 (excl.) if it has a size of 32 bit. */ LIBICAL_ICAL_EXPORT time_t icaltime_as_timet(const struct icaltimetype); |