svn commit: r244747 - head/lib/libutil
Pawel Jakub Dawidek
pjd at FreeBSD.org
Fri Dec 28 06:24:35 UTC 2012
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20121228/9516e8d8/attachment.sig>
More information about the svn-src-head
mailing list