From owner-svn-src-head@FreeBSD.ORG Fri Dec 28 06:24:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BE5BB115; Fri, 28 Dec 2012 06:24:35 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (garage.dawidek.net [91.121.88.72]) by mx1.freebsd.org (Postfix) with ESMTP id D29258FC0A; Fri, 28 Dec 2012 06:24:34 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id 48FE3B22; Fri, 28 Dec 2012 07:22:14 +0100 (CET) Date: Fri, 28 Dec 2012 07:24:34 +0100 From: Pawel Jakub Dawidek To: Baptiste Daroussin Subject: Re: svn commit: r244747 - head/lib/libutil Message-ID: <20121228062434.GG1400@garage.freebsd.pl> References: <201212272047.qBRKlYNQ053993@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+sHJum3is6Tsg7/J" Content-Disposition: inline In-Reply-To: <201212272047.qBRKlYNQ053993@svn.freebsd.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Dec 2012 06:24:35 -0000 --+sHJum3is6Tsg7/J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 27, 2012 at 08:47:34PM +0000, Baptiste Daroussin wrote: > Author: bapt > Date: Thu Dec 27 20:47:34 2012 > New Revision: 244747 > URL: http://svnweb.freebsd.org/changeset/base/244747 >=20 > Log: > avoid arithmetic on uintptr_t /* point dst after the end of all the gr_mem pointers in newgr */ dst =3D (char *)newgr + sizeof(struct group) + (num_mem + 1) * sizeof(*gr->gr_mem); Wouldn't it look better to do something like this (untested): dst =3D (char *)&newgr->gr_mem[num_mem + 1]; In the code below I think you should reset newgr memebers (gr_name, gr_passwd and gr_mem) to NULL if their corresponding gr members are NULL. if (gr->gr_name !=3D NULL) { newgr->gr_name =3D dst; dst =3D stpcpy(dst, gr->gr_name) + 1; } if (gr->gr_passwd !=3D NULL) { newgr->gr_passwd =3D dst; dst =3D stpcpy(dst, gr->gr_passwd) + 1; } newgr->gr_gid =3D gr->gr_gid; if (gr->gr_mem !=3D NULL) { for (ndx =3D 0; ndx < num_mem; ndx++) { newgr->gr_mem[ndx] =3D dst; dst =3D stpcpy(dst, gr->gr_mem[ndx]) + 1; } newgr->gr_mem[ndx] =3D NULL; } --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --+sHJum3is6Tsg7/J Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlDdOyIACgkQForvXbEpPzSspACg6VOm7nTvwRy0bP1xw/EqEyoj or8AoLgYE4wW0cCqfBDRHQxWCyJw2JEv =xZyP -----END PGP SIGNATURE----- --+sHJum3is6Tsg7/J--