From 6e60ed822c0d68a98d10a76ed37cdfb2cb176236 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Thu, 25 Mar 2004 23:08:23 +0000 Subject: * time/unix/time.c (apr_time_exp_get): Remove year check that failed for 2038, use apr_time_t to avoid overflow. * time/win32/time.c (apr_time_exp_get): ditto * test/testtime.c (test_2038): Add regression test. Submitted by: Philip Martin git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@65026 13f79535-47bb-0310-9956-ffa450edef68 --- time/unix/time.c | 9 ++------- time/win32/time.c | 10 ++-------- 2 files changed, 4 insertions(+), 15 deletions(-) (limited to 'time') diff --git a/time/unix/time.c b/time/unix/time.c index 1af56e643..507d71014 100644 --- a/time/unix/time.c +++ b/time/unix/time.c @@ -135,16 +135,11 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) { - int year; - time_t days; + apr_time_t year = xt->tm_year; + apr_time_t days; static const int dayoffset[12] = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; - year = xt->tm_year; - if (year < 70 || ((sizeof(time_t) <= 4) && (year >= 138))) { - return APR_EBADDATE; - } - /* shift new year to 1st March in order to make leap year calc easy */ if (xt->tm_mon < 2) diff --git a/time/win32/time.c b/time/win32/time.c index 59ffcc43e..35743b3d2 100644 --- a/time/win32/time.c +++ b/time/win32/time.c @@ -218,17 +218,11 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt) { - int year; - time_t days; + apr_time_t year = xt->tm_year; + apr_time_t days; static const int dayoffset[12] = {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275}; - year = xt->tm_year; - - if (year < 70 || ((sizeof(time_t) <= 4) && (year >= 138))) { - return APR_EBADDATE; - } - /* shift new year to 1st March in order to make leap year calc easy */ if (xt->tm_mon < 2) -- cgit v1.2.1