Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 1999 05:50:02 -0700 (PDT)
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/10131: bug in strptime(3) 
Message-ID:  <199906221250.FAA41607@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/10131; it has been noted by GNATS.

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: tadf@kt.rim.or.jp
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/10131: bug in strptime(3) 
Date: Tue, 22 Jun 1999 14:45:36 +0200

 For a patch this small, it's probably safe to include it directly,
 rather than uuencoding it.
 
 I've attached a plaintext copy here so that it gets into the PR as
 feedback. Note that the last hunk of the diff applies 2 lines offset. Be
 sure to send feedback if this diff is not being applied to CURRENT
 source (rev 1.6) as intended.
 
 Ciao,
 Sheldon.
 
 --- strptime.c.orig	Sun Sep 13 07:20:40 1998
 +++ strptime.c	Mon Feb 15 00:34:16 1999
 @@ -159,10 +159,10 @@
  				i *= 10;
  				i += *buf - '0';
  			}
 -			if (i > 365)
 +			if (i < 1 || i > 366)
  				return 0;
  
 -			tm->tm_yday = i;
 +			tm->tm_yday = i - 1;
  			break;
  
  		case 'M':
 @@ -177,8 +177,13 @@
  				i *= 10;
  				i += *buf - '0';
  			}
 -			if (i > 59)
 -				return 0;
 +			if (c == 'M') {
 +				if (i > 59)
 +					return 0;
 +			} else {
 +				if (i > 60)
 +					return 0;
 +			}
  
  			if (c == 'M')
  				tm->tm_min = i;
 @@ -259,6 +264,24 @@
  			buf += len;
  			break;
  
 +		case 'w':
 +			if (!isdigit((unsigned char)*buf))
 +				return 0;
 +
 +			for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
 +				i *= 10;
 +				i += *buf - '0';
 +			}
 +			if (i > 6)
 +				return 0;
 +
 +			tm->tm_wday = i;
 +
 +			if (*buf != 0 && isspace((unsigned char)*buf))
 +				while (*ptr != 0 && !isspace((unsigned char)*ptr))
 +					ptr++;
 +			break;
 +
  		case 'd':
  		case 'e':
  			if (!isdigit((unsigned char)*buf))
 @@ -337,6 +360,23 @@
  				return 0;
  
  			tm->tm_year = i;
 +
 +			if (*buf != 0 && isspace((unsigned char)*buf))
 +				while (*ptr != 0 && !isspace((unsigned char)*ptr))
 +					ptr++;
 +			break;
 +
 +		case 'U':
 +		case 'W':
 +			if (!isdigit((unsigned char)*buf))
 +				return 0;
 +
 +			for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
 +				i *= 10;
 +				i += *buf - '0';
 +			}
 +			if (i > 53)
 +				return 0;
  
  			if (*buf != 0 && isspace((unsigned char)*buf))
  				while (*ptr != 0 && !isspace((unsigned char)*ptr))
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906221250.FAA41607>