From 9ee906bbd3ca844c465c6f1056ac025ccca948e3 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 26 Dec 2012 23:14:33 +0000 Subject: Fix off-by-one error in memory allocation: j entries, one new and a null terminator is j + 2. Submitted by: Christoph Mallon --- pw/pw_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pw') diff --git a/pw/pw_user.c b/pw/pw_user.c index 7df6b85..43119ed 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -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]; -- cgit v1.2.3