bin/63064: strptime(3) fails %z

N.J. Mann njm at njm.me.uk
Tue Sep 23 16:50:04 UTC 2008


The following reply was made to PR bin/63064; it has been noted by GNATS.

From: "N.J. Mann" <njm at njm.me.uk>
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: bin/63064: strptime(3) fails %z
Date: Tue, 23 Sep 2008 17:16:47 +0100

 --UlVJffcvxoiEqYs2
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 I have been using an updated version of this patch (see below for my own
 version) for over a year (6-STABLE and recently 7-STABLE) as part of my
 anti-spam measures (date(1) called from procmail(1)) - if the date of a
 message is more than one hour in the future or two days in the past it
 is suspicious - with great affect.  I would really like to see this, or
 something very similar, incorporated into the official version of
 strptime(3).
 
 
 --UlVJffcvxoiEqYs2
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="strptime.%z.patch.txt"
 
 --- lib/libc/stdtime/strptime.c~	2003-11-17 04:19:15.000000000 +0000
 +++ lib/libc/stdtime/strptime.c	2007-08-27 18:40:00.000000000 +0100
 @@ -490,6 +490,28 @@
  					ptr++;
  			break;
  
 +		case 'z':
 +			{
 +			int sign;
 +
 +			if (*buf != '+' && *buf != '-')
 +				break;
 +
 +			sign = (*buf++ == '-') ? -1 : +1;
 +
 +			len = 4;
 +			for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) {
 +				i *= 10;
 +				i += *buf - '0';
 +				len--;
 +			}
 +
 +			tm->tm_hour -= sign * (i / 100);
 +			tm->tm_min -= sign * (i % 100);
 +			*GMTp = 1;
 +			}
 +			break;
 +
  		case 'Z':
  			{
  			const char *cp;
 
 --UlVJffcvxoiEqYs2--


More information about the freebsd-bugs mailing list