[Pkg-shadow-commits] r3319 - in upstream/trunk: . libmisc

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Jun 2 18:40:06 UTC 2011


Author: nekral-guest
Date: 2011-06-02 18:40:06 +0000 (Thu, 02 Jun 2011)
New Revision: 3319

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/find_new_gid.c
   upstream/trunk/libmisc/find_new_uid.c
Log:
	* libmisc/find_new_uid.c, libmisc/find_new_gid.c: Add missing
	memory allocation check.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2011-06-02 15:36:29 UTC (rev 3318)
+++ upstream/trunk/ChangeLog	2011-06-02 18:40:06 UTC (rev 3319)
@@ -1,5 +1,10 @@
-2010-06-02  Cal Peake  <cp at absolutedigital.net>
+2011-06-02  Peter Vrabec  <pvrabec at redhat.com>
 
+	* libmisc/find_new_uid.c, libmisc/find_new_gid.c: Add missing
+	memory allocation check.
+
+2011-06-02  Cal Peake  <cp at absolutedigital.net>
+
 	* NEWS, libmisc/addgrps.c: Fix allocator loop. Continue to
 	getgroups() when getgroups fails (-1) with errno==EINVAL.
 

Modified: upstream/trunk/libmisc/find_new_gid.c
===================================================================
--- upstream/trunk/libmisc/find_new_gid.c	2011-06-02 15:36:29 UTC (rev 3318)
+++ upstream/trunk/libmisc/find_new_gid.c	2011-06-02 18:40:06 UTC (rev 3319)
@@ -32,6 +32,7 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "prototypes.h"
 #include "groupio.h"
@@ -75,7 +76,13 @@
 			                Prog, (unsigned long) gid_min, getdef_ulong ("GID_MIN", 1000UL), (unsigned long) gid_max);
 		}
 	}
-	used_gids = alloca (sizeof (bool) * (gid_max +1));
+	used_gids = malloc (sizeof (bool) * (gid_max +1));
+	if (NULL == used_gids) {
+		fprintf (stderr,
+		         _("%s: failed to allocate memory: %s\n"),
+		         Prog, strerror (errno));
+		return -1;
+	}
 	memset (used_gids, false, sizeof (bool) * (gid_max + 1));
 
 	if (   (NULL != preferred_gid)
@@ -189,6 +196,7 @@
 		}
 	}
 
+	free (used_gids);
 	*gid = group_id;
 	return 0;
 }

Modified: upstream/trunk/libmisc/find_new_uid.c
===================================================================
--- upstream/trunk/libmisc/find_new_uid.c	2011-06-02 15:36:29 UTC (rev 3318)
+++ upstream/trunk/libmisc/find_new_uid.c	2011-06-02 18:40:06 UTC (rev 3319)
@@ -32,6 +32,7 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "prototypes.h"
 #include "pwio.h"
@@ -75,7 +76,13 @@
 			                Prog, (unsigned long) uid_min, getdef_ulong ("UID_MIN", 1000UL), (unsigned long) uid_max);
 		}
 	}
-	used_uids = alloca (sizeof (bool) * (uid_max +1));
+	used_uids = malloc (sizeof (bool) * (uid_max +1));
+	if (NULL == used_uids) {
+		fprintf (stderr,
+		         _("%s: failed to allocate memory. %s\n"),
+		         Prog, strerror (errno));
+		return -1;
+	}
 	memset (used_uids, false, sizeof (bool) * (uid_max + 1));
 
 	if (   (NULL != preferred_uid)
@@ -189,6 +196,7 @@
 		}
 	}
 
+	free (used_uids);
 	*uid = user_id;
 	return 0;
 }




More information about the Pkg-shadow-commits mailing list