You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@locus.apache.org on 2000/07/26 20:44:05 UTC

cvs commit: apache-2.0/src/main util_date.c

rbb         00/07/26 11:44:03

  Modified:    src      CHANGES
               src/main util_date.c
  Log:
  Fix a bug in our time parsing.  We need to zero out a few fields so that
  the imploded date is valid.
  PR:	6266
  
  Revision  Changes    Path
  1.181     +7 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.180
  retrieving revision 1.181
  diff -u -r1.180 -r1.181
  --- CHANGES	2000/07/26 13:48:14	1.180
  +++ CHANGES	2000/07/26 18:43:56	1.181
  @@ -1,4 +1,11 @@
   Changes with Apache 2.0a5
  +  *) Fix a bug in the time handling.  Basically, we were imploding a time
  +     in ap_parseHTTPdate, but it had bogus data in the exploded time format.
  +     Namely, tm_usec and tm_gmtoff were not filled out.  ap_implode_time
  +     uses those two fields to adjust the time value.  Because of the HTTP
  +     spec, both of those values can be zero'ed out safely.  This fixes
  +     the bug correctly.  [Ryan Bloom]
  +
     *) Fix a couple of place in the Windows code where the wrong error
        code was being return. [Gregory Nicholls <gn...@level8.com>]
   
  
  
  
  1.13      +17 -6     apache-2.0/src/main/util_date.c
  
  Index: util_date.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_date.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- util_date.c	2000/06/12 23:02:51	1.12
  +++ util_date.c	2000/07/26 18:44:01	1.13
  @@ -201,7 +201,7 @@
       while (*date && ap_isspace(*date))	/* Find first non-whitespace char */
   	++date;
   
  -    if (*date == '\0')
  +    if (*date == '\0') 
   	return BAD_DATE;
   
       if ((date = strchr(date, ' ')) == NULL)	/* Find space after weekday */
  @@ -234,7 +234,7 @@
       }
       else if (ap_checkmask(date, "@$$ ~# ##:##:## ####*")) {	/* asctime format  */
   	ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100;
  -	if (ds.tm_year < 0)
  +	if (ds.tm_year < 0) 
   	    return BAD_DATE;
   
   	ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0');
  @@ -249,7 +249,7 @@
   	monstr = date;
   	timstr = date + 7;
       }
  -    else
  +    else 
   	return BAD_DATE;
   
       if (ds.tm_mday <= 0 || ds.tm_mday > 31)
  @@ -259,7 +259,7 @@
       ds.tm_min = ((timstr[3] - '0') * 10) + (timstr[4] - '0');
       ds.tm_sec = ((timstr[6] - '0') * 10) + (timstr[7] - '0');
   
  -    if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61))
  +    if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61)) 
   	return BAD_DATE;
   
       mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2];
  @@ -284,8 +284,19 @@
   
       ds.tm_mon = mon;
   
  -    if (ap_implode_time(&result, &ds) != APR_SUCCESS) {
  +    /* ap_mplode_time uses tm_usec and tm_gmtoff fields, but they haven't 
  +     * been set yet. 
  +     * It should be safe to just zero out these values.
  +     * tm_usec is the number of microseconds into the second.  HTTP only
  +     * cares about second granularity.
  +     * tm_gmtoff is the number of seconds off of GMT the time is.  By
  +     * definition all times going through this function are in GMT, so this
  +     * is zero. 
  +     */
  +    ds.tm_usec = 0;
  +    ds.tm_gmtoff = 0;
  +    if (ap_implode_time(&result, &ds) != APR_SUCCESS) 
   	return BAD_DATE;
  -    }
  +    
       return result;
   }