diff options
author | DJ Delorie <dj@redhat.com> | 2000-08-29 22:59:26 +0400 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-08-29 22:59:26 +0400 |
commit | 4f2aac14aaa7e3b629cabdd862959c411abff15d (patch) | |
tree | 5d36224379a13d55232c16c045ad83537c4c671e /winsup/cygwin/grp.cc | |
parent | 00a2f168e725bb10753885e227e22a8a279c71c6 (diff) |
* grp.cc (getgroups): fail with EINVAL if array is not large
enough to hold all supplementary group IDs.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r-- | winsup/cygwin/grp.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 85d9aa80d..a4af840f3 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -15,10 +15,12 @@ details. */ #include <grp.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> #include "thread.h" #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "cygerrno.h" /* Read /etc/group only once for better performance. This is done on the first call that needs information from it. */ @@ -248,8 +250,8 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username) if (cnt < gidsetsize) grouplist[cnt] = group_buf[i].gr_gid; ++cnt; - if (gidsetsize && cnt >= gidsetsize) - goto out; + if (gidsetsize && cnt > gidsetsize) + goto error; } else if (group_buf[i].gr_mem) for (int gi = 0; group_buf[i].gr_mem[gi]; ++gi) @@ -258,11 +260,14 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username) if (cnt < gidsetsize) grouplist[cnt] = group_buf[i].gr_gid; ++cnt; - if (gidsetsize && cnt >= gidsetsize) - goto out; + if (gidsetsize && cnt > gidsetsize) + goto error; } -out: return cnt; + +error: + set_errno ( EINVAL ); + return -1; } extern "C" |