apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Martin <phi...@codematters.co.uk>
Subject [PATCH] Date limit in apr_time_exp_get
Date Tue, 23 Mar 2004 20:26:37 GMT
"Roy T. Fielding" <fielding@gbiv.com> writes:

> Another bug due to a sloppy change from time_t to apr_time_t.
> Change days to apr_time_t and remove the above conditional
> (the case of year < 70 is already handled a few lines below).

* 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


Index: time/unix/time.c
===================================================================
RCS file: /home/cvspublic/apr/time/unix/time.c,v
retrieving revision 1.73.2.1
diff -u -r1.73.2.1 time.c
--- time/unix/time.c	13 Feb 2004 09:33:55 -0000	1.73.2.1
+++ time/unix/time.c	23 Mar 2004 20:04:55 -0000
@@ -135,15 +135,10 @@
 
 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 */
 
Index: time/win32/time.c
===================================================================
RCS file: /home/cvspublic/apr/time/win32/time.c,v
retrieving revision 1.46.2.1
diff -u -r1.46.2.1 time.c
--- time/win32/time.c	13 Feb 2004 09:33:55 -0000	1.46.2.1
+++ time/win32/time.c	23 Mar 2004 20:04:55 -0000
@@ -218,16 +218,10 @@
 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 */
 

-- 
Philip Martin

Mime
View raw message