From owner-freebsd-bugs Wed May 30 4: 0:19 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 09FBD37B422 for ; Wed, 30 May 2001 04:00:16 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f4UB0FY39687; Wed, 30 May 2001 04:00:15 -0700 (PDT) (envelope-from gnats) Date: Wed, 30 May 2001 04:00:15 -0700 (PDT) Message-Id: <200105301100.f4UB0FY39687@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: bin/27757: Wrong format specifiers in chpass(1) Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/27757; it has been noted by GNATS. From: Bruce Evans To: Yoshihiro Koya 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