aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-22 23:40:28 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-22 23:40:28 +0000
commitf614e45aaaf139b89cd02505c5aed3278350e305 (patch)
treebe1be2a0dadab03bb2ca20751b0c60524a53dcb1
parentd26178a47b0c836ef9eec94c8a3617bd638c3f58 (diff)
downloadbusybox-w32-f614e45aaaf139b89cd02505c5aed3278350e305.tar.gz
busybox-w32-f614e45aaaf139b89cd02505c5aed3278350e305.tar.bz2
busybox-w32-f614e45aaaf139b89cd02505c5aed3278350e305.zip
"Jordan Crouse" <jordan.crouse@amd.com> says:
The following patch makes coreutils/test.c act fail gracefully if getgroups() returns a -1.  This fixes a problem on the One Laptop Per Child ROM image whereby we were getting odd Memory exhausted messages for '[' and 'test'. Found by Mitch Bradley <wmb@firmworks.com> (Tweaked by Rob: no need to initialize a static to NULL, or realloc something that's only allocated when it's NULL.) git-svn-id: svn://busybox.net/trunk/busybox@15905 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/test.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index bbc802283..c1097c28c 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -151,7 +151,7 @@ typedef int arith_t;
151 151
152static char **t_wp; 152static char **t_wp;
153static struct t_op const *t_wp_op; 153static struct t_op const *t_wp_op;
154static gid_t *group_array = NULL; 154static gid_t *group_array;
155static int ngroups; 155static int ngroups;
156 156
157static enum token t_lex(char *s); 157static enum token t_lex(char *s);
@@ -547,8 +547,10 @@ static int test_eaccess(char *path, int mode)
547static void initialize_group_array(void) 547static void initialize_group_array(void)
548{ 548{
549 ngroups = getgroups(0, NULL); 549 ngroups = getgroups(0, NULL);
550 group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); 550 if (ngroups > 0) {
551 getgroups(ngroups, group_array); 551 group_array = xmalloc(ngroups * sizeof(gid_t));
552 getgroups(ngroups, group_array);
553 }
552} 554}
553 555
554/* Return non-zero if GID is one that we have in our groups list. */ 556/* Return non-zero if GID is one that we have in our groups list. */