blob: 6fb2daf532ec825442b431a55c2285e9aac42b60 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001Upstream-Status: Backport
2
3Signed-off-by: Kai Kang <kai.kang@windriver.com>
4---
5From feca6d2e55d992bbe176ee8faa734c105eb1b2e1 Mon Sep 17 00:00:00 2001
6From: Theodore Ts'o <tytso@mit.edu>
7Date: Tue, 29 Mar 2016 20:48:05 -0400
8Subject: [PATCH] Use NGROUPS_MAX instead of NGROUPS
9
10NGRROUPS_MAX is what is defined by SuSv3; NGROUPS is not guaranteed by
11any standard, but is just an ancient BSD'ism. Since Android's bionic
12libc has the former but not the latter, let's use NGROUPS_MAX instead.
13
14Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15Signed-off-by: Jan Kara <jack@suse.cz>
16---
17 quota.c | 5 +++--
18 quotaops.c | 5 +++--
19 2 files changed, 6 insertions(+), 4 deletions(-)
20
21diff --git a/quota.c b/quota.c
22index 049dac4..e195ead 100644
23--- a/quota.c
24+++ b/quota.c
25@@ -48,6 +48,7 @@
26 #include <errno.h>
27 #include <string.h>
28 #include <unistd.h>
29+#include <limits.h>
30 #ifdef RPC
31 #include <rpc/rpc.h>
32 #include "rquota.h"
33@@ -296,7 +297,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
34 int main(int argc, char **argv)
35 {
36 int ngroups;
37- gid_t gidset[NGROUPS], *gidsetp;
38+ gid_t gidset[NGROUPS_MAX], *gidsetp;
39 int i, ret;
40 struct option long_opts[] = {
41 { "help", 0, NULL, 'h' },
42@@ -405,7 +406,7 @@ int main(int argc, char **argv)
43 ret |= showquotas(USRQUOTA, getuid(), argc, argv);
44 if (flags & FL_GROUP) {
45 ngroups = sysconf(_SC_NGROUPS_MAX);
46- if (ngroups > NGROUPS) {
47+ if (ngroups > NGROUPS_MAX) {
48 gidsetp = malloc(ngroups * sizeof(gid_t));
49 if (!gidsetp)
50 die(1, _("Gid set allocation (%d): %s\n"), ngroups, strerror(errno));
51diff --git a/quotaops.c b/quotaops.c
52index 136aec3..590dc1b 100644
53--- a/quotaops.c
54+++ b/quotaops.c
55@@ -51,6 +51,7 @@
56 #include <unistd.h>
57 #include <time.h>
58 #include <ctype.h>
59+#include <limits.h>
60
61 #if defined(RPC)
62 #include "rquota.h"
63@@ -97,7 +98,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
64 #if defined(BSD_BEHAVIOUR)
65 int j, ngroups;
66 uid_t euid;
67- gid_t gidset[NGROUPS], *gidsetp;
68+ gid_t gidset[NGROUPS_MAX], *gidsetp;
69 #endif
70
71 for (i = 0; handles[i]; i++) {
72@@ -115,7 +116,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
73 if (geteuid() == 0)
74 break;
75 ngroups = sysconf(_SC_NGROUPS_MAX);
76- if (ngroups > NGROUPS) {
77+ if (ngroups > NGROUPS_MAX) {
78 gidsetp = malloc(ngroups * sizeof(gid_t));
79 if (!gidsetp) {
80 gid2group(id, name);
81--
822.6.1
83