Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2001 20:32:50 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Alexander Langer <alex@big.endian.de>, Thomas Zenker <thz@Lennartz-electronic.de>, audit@FreeBSD.ORG
Subject:   Re: bin/27029: strptime: %s formatting missing (patch) 
Message-ID:  <20010630033250.576723E32@bazooka.unixfreak.org>
In-Reply-To: <Pine.BSF.4.21.0106300111090.16573-100000@besplex.bde.org>; from bde@zeta.org.au on "Sat, 30 Jun 2001 01:23:33 %2B1000 (EST)"

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <bde@zeta.org.au> writes:
> On Thu, 28 Jun 2001, Dima Dorfman wrote:
> 
> Alexander Langer <alex@big.endian.de> writes:
> > > Also sprach Thomas Zenker (thz@Lennartz-electronic.de):
> > > > +		case 's':
> > > > +			{
> > > > +			time_t t;
> > > > +			const char *cp;
> > > > +			t = strtol(buf, &cp, 10);
> > > 
> > > Is time_t long again on all branches?
> > > I think David (obrien) backed it out on -STABLE, IIRC.
> > 
> > IIRC it's an int on most branches, but using strtol is still okay there.
> 
> Except for the usual lack of error checking for strto*().

The version I have locally (attached below), which is based on
Thomas's patch, checks for overflow, but not for whether strtol
consumed the entrie string.  Unless you (Bruce) find something wrong
with it I'd like to commit this in a few days.

Known style bugs:
 - Declaration inside a block.
 - Block not indented.
 - No parenthesis with return.
 - Returning "0" but should be "NULL".

..all of which are there to maintain what little consistency there is
in that file.

					Dima Dorfman
					dima@unixfreak.org

Index: strptime.c
===================================================================
RCS file: /stl/src/FreeBSD/src/lib/libc/stdtime/strptime.c,v
retrieving revision 1.25
diff -u -r1.25 strptime.c
--- strptime.c	2001/03/21 14:52:12	1.25
+++ strptime.c	2001/06/30 03:26:21
@@ -67,6 +67,8 @@
 #include "namespace.h"
 #include <time.h>
 #include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
 #include <string.h>
 #include <pthread.h>
 #include "un-namespace.h"
@@ -443,6 +445,20 @@
 			if (*buf != 0 && isspace((unsigned char)*buf))
 				while (*ptr != 0 && !isspace((unsigned char)*ptr))
 					ptr++;
+			break;
+
+		case 's':
+			{
+			char *cp;
+			time_t t;
+
+			t = strtol(buf, &cp, 10);
+			if (t == LONG_MAX)
+				return 0;
+			buf = cp;
+			gmtime_r(&t, tm);
+			got_GMT = 1;
+			}
 			break;
 
 		case 'Y':

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




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