28c28
< __FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 244739 2012-12-27 16:51:29Z bapt $");
---
> __FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 244742 2012-12-27 19:33:43Z bapt $");
47,51d46
< struct group_storage {
< struct group gr;
< char *members[];
< };
<
436a432
> struct group *newgr;
439d434
< struct group_storage *gs;
444c439
< len = sizeof(*gs);
---
> len = sizeof(*newgr);
455d449
<
457c451
< if ((gs = calloc(1, len)) == NULL)
---
> if ((newgr = malloc(len)) == NULL)
459c453,460
< dst = (char *)&gs->members[num_mem + 1];
---
> /* point new gr_mem to end of struct + 1 */
> if (gr->gr_mem != NULL)
> newgr->gr_mem = (char **)newgr + sizeof(struct group);
> else
> newgr->gr_mem = NULL;
> /* 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);
461,462c462,463
< gs->gr.gr_name = dst;
< dst = stpcpy(gs->gr.gr_name, gr->gr_name) + 1;
---
> newgr->gr_name = dst;
> dst = stpcpy(dst, gr->gr_name) + 1;
465,466c466,467
< gs->gr.gr_passwd = dst;
< dst = stpcpy(gs->gr.gr_passwd, gr->gr_passwd) + 1;
---
> newgr->gr_passwd = dst;
> dst = stpcpy(dst, gr->gr_passwd) + 1;
468c469
< gs->gr.gr_gid = gr->gr_gid;
---
> newgr->gr_gid = gr->gr_gid;
470d470
< gs->gr.gr_mem = gs->members;
472,473c472,473
< gs->gr.gr_mem[ndx] = dst;
< dst = stpcpy(gs->gr.gr_mem[ndx], gr->gr_mem[ndx]) + 1;
---
> newgr->gr_mem[ndx] = dst;
> dst = stpcpy(dst, gr->gr_mem[ndx]) + 1;
475c475
< gs->gr.gr_mem[ndx] = NULL;
---
> newgr->gr_mem[ndx] = NULL;
477,478c477
<
< return (&gs->gr);
---
> return (newgr);
< __FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 244739 2012-12-27 16:51:29Z bapt $");
---
> __FBSDID("$FreeBSD: head/lib/libutil/gr_util.c 244742 2012-12-27 19:33:43Z bapt $");
47,51d46
< struct group_storage {
< struct group gr;
< char *members[];
< };
<
436a432
> struct group *newgr;
439d434
< struct group_storage *gs;
444c439
< len = sizeof(*gs);
---
> len = sizeof(*newgr);
455d449
<
457c451
< if ((gs = calloc(1, len)) == NULL)
---
> if ((newgr = malloc(len)) == NULL)
459c453,460
< dst = (char *)&gs->members[num_mem + 1];
---
> /* point new gr_mem to end of struct + 1 */
> if (gr->gr_mem != NULL)
> newgr->gr_mem = (char **)newgr + sizeof(struct group);
> else
> newgr->gr_mem = NULL;
> /* 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);
461,462c462,463
< gs->gr.gr_name = dst;
< dst = stpcpy(gs->gr.gr_name, gr->gr_name) + 1;
---
> newgr->gr_name = dst;
> dst = stpcpy(dst, gr->gr_name) + 1;
465,466c466,467
< gs->gr.gr_passwd = dst;
< dst = stpcpy(gs->gr.gr_passwd, gr->gr_passwd) + 1;
---
> newgr->gr_passwd = dst;
> dst = stpcpy(dst, gr->gr_passwd) + 1;
468c469
< gs->gr.gr_gid = gr->gr_gid;
---
> newgr->gr_gid = gr->gr_gid;
470d470
< gs->gr.gr_mem = gs->members;
472,473c472,473
< gs->gr.gr_mem[ndx] = dst;
< dst = stpcpy(gs->gr.gr_mem[ndx], gr->gr_mem[ndx]) + 1;
---
> newgr->gr_mem[ndx] = dst;
> dst = stpcpy(dst, gr->gr_mem[ndx]) + 1;
475c475
< gs->gr.gr_mem[ndx] = NULL;
---
> newgr->gr_mem[ndx] = NULL;
477,478c477
<
< return (&gs->gr);
---
> return (newgr);