diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-10-05 15:43:27 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-10-05 15:43:27 +0000 |
commit | c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc (patch) | |
tree | 8a23c84995a88f0437213d280e8335708cf7b09e /grp/initgroups.c | |
parent | ddbf09971df057003d35943a9d7d9d3653a26763 (diff) | |
download | glibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.tar.gz glibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.tar.xz glibc-c25d26bbb4e1d6447b5a6b60afb2d6086796c9bc.zip |
2.3.3-65 cvs/fedora-glibc-2_3_3-65
Diffstat (limited to 'grp/initgroups.c')
-rw-r--r-- | grp/initgroups.c | 8 |
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 |