Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 May 2001 04:00:15 -0700 (PDT)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/27757: Wrong format specifiers in chpass(1)
Message-ID:  <200105301100.f4UB0FY39687@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/27757; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: Yoshihiro Koya <Yoshihiro.Koya@math.yokohama-cu.ac.jp>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/27757: Wrong format specifiers in chpass(1)
Date: Wed, 30 May 2001 20:51:53 +1000 (EST)

 On Wed, 30 May 2001, Yoshihiro Koya wrote:
 
 > >Description:
 > 	A wrong format specifier of snprintf used in sources of
 > 	chpass(1) generate a negative uid as a string.
 > 
 > Index: edit.c
 > ===================================================================
 > RCS file: /home/ncvs/src/usr.bin/chpass/edit.c,v
 > retrieving revision 1.18
 > diff -u -r1.18 edit.c
 > --- edit.c	2000/09/06 18:16:46	1.18
 > +++ edit.c	2001/05/29 21:53:59
 > @@ -255,7 +255,7 @@
 >  		pw->pw_gecos[len - 1] = '\0';
 >  
 >  	if (snprintf(buf, sizeof(buf),
 > -	    "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s",
 > +	    "%s:%s:%u:%u:%s:%ld:%ld:%s:%s:%s",
 >  	    pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class,
 >  	    pw->pw_change, pw->pw_expire, pw->pw_gecos, pw->pw_dir,
 >  	    pw->pw_shell) >= sizeof(buf)) {
 
 There are some other printf format errors here.  The default promotion of
 uid_t and gid_t is assumed to be u_int.  This just happens to be corect
 on all supported machines.  The default promotion of time_t is assumed to
 be long.  This happens to be incorrect on all supported machines (but may
 magically work).
 
 Bruce
 

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




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