From owner-freebsd-audit Fri Jun 29 20:32:54 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 2B73A37B409 for ; Fri, 29 Jun 2001 20:32:51 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 576723E32; Fri, 29 Jun 2001 20:32:50 -0700 (PDT) To: Bruce Evans Cc: Alexander Langer , Thomas Zenker , audit@FreeBSD.ORG Subject: Re: bin/27029: strptime: %s formatting missing (patch) In-Reply-To: ; from bde@zeta.org.au on "Sat, 30 Jun 2001 01:23:33 +1000 (EST)" Date: Fri, 29 Jun 2001 20:32:50 -0700 From: Dima Dorfman Message-Id: <20010630033250.576723E32@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce Evans writes: > On Thu, 28 Jun 2001, Dima Dorfman wrote: > > Alexander Langer 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 #include +#include +#include #include #include #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