svn commit: trunk/busybox/coreutils

landley at busybox.net landley at busybox.net
Tue Aug 22 23:40:29 UTC 2006


Author: landley
Date: 2006-08-22 16:40:28 -0700 (Tue, 22 Aug 2006)
New Revision: 15905

Log:
"Jordan Crouse" <jordan.crouse at amd.com> says:
The following patch makes coreutils/test.c act fail gracefully if getgroups() 
returns a -1. ?\194?\160This 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 at firmworks.com>
(Tweaked by Rob: no need to initialize a static to NULL, or realloc something
that's only allocated when it's NULL.)


Modified:
   trunk/busybox/coreutils/test.c


Changeset:
Modified: trunk/busybox/coreutils/test.c
===================================================================
--- trunk/busybox/coreutils/test.c	2006-08-22 08:03:19 UTC (rev 15904)
+++ trunk/busybox/coreutils/test.c	2006-08-22 23:40:28 UTC (rev 15905)
@@ -151,7 +151,7 @@
 
 static char **t_wp;
 static struct t_op const *t_wp_op;
-static gid_t *group_array = NULL;
+static gid_t *group_array;
 static int ngroups;
 
 static enum token t_lex(char *s);
@@ -547,8 +547,10 @@
 static void initialize_group_array(void)
 {
 	ngroups = getgroups(0, NULL);
-	group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
-	getgroups(ngroups, group_array);
+	if (ngroups > 0) {
+		group_array = xmalloc(ngroups * sizeof(gid_t));
+		getgroups(ngroups, group_array);
+	}
 }
 
 /* Return non-zero if GID is one that we have in our groups list. */




More information about the busybox-cvs mailing list