Date: Fri, 28 Dec 2012 07:24:34 +0100 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Baptiste Daroussin <bapt@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r244747 - head/lib/libutil Message-ID: <20121228062434.GG1400@garage.freebsd.pl> In-Reply-To: <201212272047.qBRKlYNQ053993@svn.freebsd.org> References: <201212272047.qBRKlYNQ053993@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--+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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121228062434.GG1400>