You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Philip Martin <ph...@codematters.co.uk> on 2004/03/23 21:26:37 UTC
[PATCH] Date limit in apr_time_exp_get
"Roy T. Fielding" <fi...@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
Re: [PATCH] Date limit in apr_time_exp_get
Posted by Joe Orton <jo...@manyfish.co.uk>.
On Tue, Mar 23, 2004 at 08:26:37PM +0000, Philip Martin wrote:
> "Roy T. Fielding" <fi...@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
Thanks Philip, I've committed this for the next release.
joe