httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@ast.cam.ac.uk (David Robinson)
Subject Re: bug and fix to: int later_than(struct tm *lms, char *ims) (fwd)
Date Fri, 20 Oct 1995 15:48:00 GMT
> From gdiener@advtech.uswest.com  Mon Oct  9 16:01:22 1995
> From: grd <gdiener@advtech.uswest.com>
> Date: Mon,  9 Oct 95 17:01:12 -0600
> Subject: bug and fix to: int later_than(struct tm *lms, char *ims)
> Cc: gdiener@advtech.uswest.com
> 
> I believe that apache 0.8.14, together with all earlier versions (and the original
> ncsa source) all have a bug in the way a string ctime / asctime is parsed.
> In the function:  int later_than(struct tm *lms, char *ims)
> (In 0.8.14, in the file http_protocol.c, lines 109:112), you will find:
> 
>     if(isalpha(*ip)) {
>         /* ctime */
>         sscanf(ip,"%s %d %d:%d:%d %*s %d",mname,&day,&hour,&min,&sec,&year);
> 
> ...the  skipped field in the scanf should not be here...there is no code to
>   skip over in the format, for example...
>       Sun Sep 16 01:03:52 1973\n\0
>           %s  %d %d:%d:%d %s
>   i.e. the code should be:
>     if(isalpha(*ip)) {
>         /* ctime */
>         sscanf(ip,"%s %d %d:%d:%d %d",mname,&day,&hour,&min,&sec,&year);
> 
> As is, the code sets the year to garbage.

I've uploaded 33_time.0.8.15.patch which fixes this.

Subject: Fix bug in time parsing
Affects: http_protocol.c
ChangeLog: Fix parsing of ctime time format
Comments: Reported by gdiener@uswest.com (glen diener)

*** http_protocol.c.orig	Tue Oct 10 23:00:27 1995
--- http_protocol.c	Fri Oct 20 15:28:03 1995
***************
*** 103,109 ****
  
      if(isalpha(*ip)) {
          /* ctime */
!         sscanf(ip,"%s %d %d:%d:%d %*s %d",mname,&day,&hour,&min,&sec,&year);
      }
      else if(ip[2] == '-') {
          /* RFC 850 (normal HTTP) */
--- 103,109 ----
  
      if(isalpha(*ip)) {
          /* ctime */
!         sscanf(ip,"%s %d %d:%d:%d %d",mname,&day,&hour,&min,&sec,&year);
      }
      else if(ip[2] == '-') {
          /* RFC 850 (normal HTTP) */

Mime
View raw message