From c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Oct 2004 15:43:27 +0000 Subject: 2.3.3-65 --- grp/initgroups.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'grp/initgroups.c') diff --git a/grp/initgroups.c b/grp/initgroups.c index 5a3edecf09..d052cf48f7 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -112,9 +112,9 @@ internal_getgrouplist (const char *user, gid_t group, long int *size, break; if (inner < prev_start) - ++cnt; - else (*groupsp)[cnt] = (*groupsp)[--start]; + else + ++cnt; } /* This is really only for debugging. */ @@ -141,10 +141,10 @@ int getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) { gid_t *newgroups; - long int size = *ngroups; + long int size = MAX (1, *ngroups); int result; - newgroups = (gid_t *) malloc (size * sizeof (gid_t)); + newgroups = (gid_t *) malloc ((size + 1) * sizeof (gid_t)); if (__builtin_expect (newgroups == NULL, 0)) /* No more memory. */ // XXX This is wrong. The user provided memory, we have to use -- cgit 1.4.1