Fix off-by-one error in memory allocation: j entries, one new and a null

terminator is j + 2.

Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
This commit is contained in:
Baptiste Daroussin 2012-12-26 23:14:33 +00:00
parent 7716eb4c40
commit c195c1ba19
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=244720

View File

@ -756,7 +756,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (grp->gr_mem[j] != NULL) /* user already member of group */
continue;
members = malloc(sizeof(char *) * (j + 1));
members = malloc(sizeof(char *) * (j + 2));
for (j = 0; grp->gr_mem[j] != NULL; j++)
members[j] = grp->gr_mem[j];