aboutsummaryrefslogtreecommitdiff
path: root/grp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-10-05 15:43:27 +0000
committerJakub Jelinek <jakub@redhat.com>2004-10-05 15:43:27 +0000
commitc25d26bbb4e1d6447b5a6b60afb2d6086796c9bc (patch)
tree8a23c84995a88f0437213d280e8335708cf7b09e /grp
parentFix atomic.h warnings on i386 in nscd. (diff)
downloadglibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.tar.gz
glibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.tar.bz2
glibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.zip
Diffstat (limited to 'grp')
-rw-r--r--grp/initgroups.c8
1 files changed, 4 insertions, 4 deletions
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