Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Nov 2001 17:17:05 -0500
From:      Dave Chapeskie <freebsd@ddm.wox.org>
To:        audit@FreeBSD.ORG
Cc:        "Sergey A . Osokin" <osa@freebsd.org.ru>
Subject:   Re: date(1) WARNS=2 cleanup
Message-ID:  <20011123171705.A2462@ddm.wox.org>
In-Reply-To: <20011123161136.A11027@freebsd.org.ru>; from osa@freebsd.org.ru on Fri, Nov 23, 2001 at 04:11:36PM %2B0300
References:  <20011123150934.A10406@freebsd.org.ru> <20011123161136.A11027@freebsd.org.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <libutil.h> 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




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