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

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sat Aug 30 18:29:09 UTC 2008


Author: nekral-guest
Date: 2008-08-30 18:29:08 +0000 (Sat, 30 Aug 2008)
New Revision: 2292

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/NEWS
   upstream/trunk/libmisc/list.c
   upstream/trunk/src/groupmems.c
Log:
	* src/groupmems.c: When removing an user, check if deluser is on
	the list, not adduser. This fixes a segmentation fault for every
	call of groupmems -d.
	* libmisc/list.c: Add assertions to help identifying these issues.
	* libmisc/list.c: Avoid implicit conversion of pointers to
	booleans.

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-08-30 18:28:45 UTC (rev 2291)
+++ upstream/trunk/ChangeLog	2008-08-30 18:29:08 UTC (rev 2292)
@@ -1,5 +1,14 @@
 2008-08-26  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/groupmems.c: When removing an user, check if deluser is on
+	the list, not adduser. This fixes a segmentation fault for every
+	call of groupmems -d.
+	* libmisc/list.c: Add assertions to help identifying these issues.
+	* libmisc/list.c: Avoid implicit conversion of pointers to
+	booleans.
+
+2008-08-26  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* NEWS, src/groupmems.c: Use the "groupmems" PAM service name
 	instead of "groupmod".
 

Modified: upstream/trunk/NEWS
===================================================================
--- upstream/trunk/NEWS	2008-08-30 18:28:45 UTC (rev 2291)
+++ upstream/trunk/NEWS	2008-08-30 18:29:08 UTC (rev 2292)
@@ -18,6 +18,7 @@
     group.
   * Added syslog support.
   * Use the groupmems PAM service name instead of groupmod.
+  * Fix segmentation faults when adding or removing users from a group.
 - newusers
   * Implement the -r, --system option.
 - passwd

Modified: upstream/trunk/libmisc/list.c
===================================================================
--- upstream/trunk/libmisc/list.c	2008-08-30 18:28:45 UTC (rev 2291)
+++ upstream/trunk/libmisc/list.c	2008-08-30 18:29:08 UTC (rev 2292)
@@ -50,6 +50,8 @@
 	int i;
 	char **tmp;
 
+	assert (NULL != member);
+
 	/*
 	 * Scan the list for the new name.  Return the original list
 	 * pointer if it is present.
@@ -97,6 +99,8 @@
 	int i, j;
 	char **tmp;
 
+	assert (NULL != member);
+
 	/*
 	 * Scan the list for the old name.  Return the original list
 	 * pointer if it is not present.
@@ -142,12 +146,12 @@
 	int i;
 	char **tmp;
 
-	for (i = 0; list[i]; i++);
+	for (i = 0; NULL != list[i]; i++);
 
 	tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
 
 	i = 0;
-	while (*list) {
+	while (NULL != *list) {
 		tmp[i] = xstrdup (*list);
 		i++;
 		list++;
@@ -159,12 +163,15 @@
 
 bool is_on_list (char *const *list, const char *member)
 {
-	while (*list) {
+	assert (NULL != member);
+
+	while (NULL != *list) {
 		if (strcmp (*list, member) == 0) {
 			return true;
 		}
 		list++;
 	}
+
 	return false;
 }
 
@@ -179,6 +186,8 @@
 	int i;
 	char *cp, *cp2;
 
+	assert (NULL != comma);
+
 	/*
 	 * Make a copy since we are going to be modifying the list
 	 */

Modified: upstream/trunk/src/groupmems.c
===================================================================
--- upstream/trunk/src/groupmems.c	2008-08-30 18:28:45 UTC (rev 2291)
+++ upstream/trunk/src/groupmems.c	2008-08-30 18:29:08 UTC (rev 2292)
@@ -291,7 +291,7 @@
 			fail_exit (13);
 		}
 	} else if (NULL != deluser) {
-		if (!is_on_list (grp->gr_mem, adduser)) {
+		if (!is_on_list (grp->gr_mem, deluser)) {
 			fprintf (stderr,
 			         _("%s: user '%s' is not a member of '%s'\n"),
 			         Prog, deluser, grp->gr_name);




More information about the Pkg-shadow-commits mailing list