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
[-- Attachment #1 --] 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 > > Log: > avoid arithmetic on uintptr_t /* point dst after the end of all the gr_mem pointers in newgr */ dst = (char *)newgr + sizeof(struct group) + (num_mem + 1) * sizeof(*gr->gr_mem); Wouldn't it look better to do something like this (untested): dst = (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 != NULL) { newgr->gr_name = dst; dst = stpcpy(dst, gr->gr_name) + 1; } if (gr->gr_passwd != NULL) { newgr->gr_passwd = dst; dst = stpcpy(dst, gr->gr_passwd) + 1; } newgr->gr_gid = gr->gr_gid; if (gr->gr_mem != NULL) { for (ndx = 0; ndx < num_mem; ndx++) { newgr->gr_mem[ndx] = dst; dst = stpcpy(dst, gr->gr_mem[ndx]) + 1; } newgr->gr_mem[ndx] = NULL; } -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlDdOyIACgkQForvXbEpPzSspACg6VOm7nTvwRy0bP1xw/EqEyoj or8AoLgYE4wW0cCqfBDRHQxWCyJw2JEv =xZyP -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121228062434.GG1400>
