summaryrefslogtreecommitdiffstats
path: root/usr.bin/quota/quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/quota/quota.c')
-rw-r--r--usr.bin/quota/quota.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c
index 503b43d..f504e7c 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);
}
OpenPOWER on IntegriCloud