From owner-freebsd-audit Fri Nov 23 14:17:55 2001 Delivered-To: freebsd-audit@freebsd.org Received: from squigy.ddm.wox.org (p26.argon2.sentex.ca [206.51.25.58]) by hub.freebsd.org (Postfix) with ESMTP id 13AD537B405 for ; Fri, 23 Nov 2001 14:17:51 -0800 (PST) Received: from rama.ddm.wox.org (rama.ddm.wox.org [204.50.152.20]) by squigy.ddm.wox.org (Postfix) with ESMTP id 692D48BAD5; Fri, 23 Nov 2001 17:17:49 -0500 (EST) Received: by rama.ddm.wox.org (Postfix, from userid 5000) id B4CFD32000; Fri, 23 Nov 2001 17:17:05 -0500 (EST) Date: Fri, 23 Nov 2001 17:17:05 -0500 From: Dave Chapeskie To: audit@FreeBSD.ORG Cc: "Sergey A . Osokin" Subject: Re: date(1) WARNS=2 cleanup Message-ID: <20011123171705.A2462@ddm.wox.org> Mail-Followup-To: Dave Chapeskie , audit@FreeBSD.ORG, "Sergey A . Osokin" References: <20011123150934.A10406@freebsd.org.ru> <20011123161136.A11027@freebsd.org.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20011123161136.A11027@freebsd.org.ru>; from osa@freebsd.org.ru on Fri, Nov 23, 2001 at 04:11:36PM +0300 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 On Fri, Nov 23, 2001 at 04:11:36PM +0300, Sergey A. Osokin wrote: > @@ -71,7 +71,7 @@ > static void badformat __P((void)); > static void usage __P((void)); > > -int logwtmp __P((char *, char *, char *)); > +int logwtmp __P((const char *, const char *, const char *)); The manual page for logwtmp() clearly states that needs to be included, the correct prototype is there. Remove the bogus prototype from date.c and include libutil.h instead. > int > main(argc, argv) > @@ -148,7 +148,7 @@ > if (!rflag && time(&tval) == -1) > err(1, "time"); > > - format = "%+"; > + format = strdup("%+"); This change is incorrect. Strdup allocates memory which you never free. The correct solution to the warning created by this line is to change the type of 'format' from "char *" to "const char *". > diff -ruN date.orig/vary.c date/vary.c > --- date.orig/vary.c Fri Nov 23 10:57:45 2001 > +++ date/vary.c Fri Nov 23 13:08:31 2001 > @@ -430,7 +430,7 @@ > if (type == '\0') > t->tm_isdst = -1; > > - if (strspn(arg, digits) != len-1) { > + if ((int)strspn(arg, digits) != len-1) { > val = trans(trans_wday, arg); > if (val != -1) { > if (!adjwday(t, type, val, 1, 1)) A more appropriate fix is to change the type of 'len' from int to size_t, 'len' is initially assigned the return of strlen() which is also a size_t. -- Dave Chapeskie OpenPGP Key ID: 0x3D2B6B34 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message