diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
commit | 54404cfb13d40e474f72d3c75de1f4db3417df64 (patch) | |
tree | b7d4401847de9bebf98c6fe35d5b61bfd749c7dc /usr.bin/quota | |
parent | 68cc62cec1384a3e08391dc734b0ff16f6eda869 (diff) | |
download | src-test2-54404cfb13d40e474f72d3c75de1f4db3417df64.tar.gz src-test2-54404cfb13d40e474f72d3c75de1f4db3417df64.zip |
Notes
Diffstat (limited to 'usr.bin/quota')
-rw-r--r-- | usr.bin/quota/quota.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c index 503b43d5233f..f504e7c31593 100644 --- a/usr.bin/quota/quota.c +++ b/usr.bin/quota/quota.c @@ -117,7 +117,8 @@ int main(int argc, char *argv[]) { int ngroups; - gid_t mygid, gidset[NGROUPS]; + long ngroups_max; + gid_t mygid, *gidset; int i, ch, gflag = 0, uflag = 0, errflag = 0; while ((ch = getopt(argc, argv, "f:ghlrquv")) != -1) { @@ -159,13 +160,18 @@ main(int argc, char *argv[]) errflag += showuid(getuid()); if (gflag) { mygid = getgid(); - ngroups = getgroups(NGROUPS, gidset); + ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1; + if ((gidset = malloc(sizeof(gid_t) * ngroups_max)) + == NULL) + err(1, "malloc"); + ngroups = getgroups(ngroups_max, gidset); if (ngroups < 0) err(1, "getgroups"); errflag += showgid(mygid); for (i = 0; i < ngroups; i++) if (gidset[i] != mygid) errflag += showgid(gidset[i]); + free(gidset); } return(errflag); } |