Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jun 2014 18:51:19 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267970 - head/usr.sbin/pw
Message-ID:  <201406271851.s5RIpJfa042581@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Fri Jun 27 18:51:19 2014
New Revision: 267970
URL: http://svnweb.freebsd.org/changeset/base/267970

Log:
  pw: fix up deletion of users from groups
  
  Previuosly given 'foo,bar' members, removing 'foo' would result in an
  infinite loop.
  
  PR:		191427
  Submitted by:	Voradesh Yenbut <yenbut cs.washington.edu>
  MFC after:	1 week

Modified:
  head/usr.sbin/pw/pw_user.c

Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c	Fri Jun 27 18:40:14 2014	(r267969)
+++ head/usr.sbin/pw/pw_user.c	Fri Jun 27 18:51:19 2014	(r267970)
@@ -438,14 +438,13 @@ pw_user(struct userconf * cnf, int mode,
 				delgrent(GETGRNAM(a_name->val));
 			SETGRENT();
 			while ((grp = GETGRENT()) != NULL) {
-				int i;
+				int i, j;
 				char group[MAXLOGNAME];
 				if (grp->gr_mem != NULL) {
 					for (i = 0; grp->gr_mem[i] != NULL; i++) {
 						if (!strcmp(grp->gr_mem[i], a_name->val)) {
-							while (grp->gr_mem[i] != NULL) {
-								grp->gr_mem[i] = grp->gr_mem[i+1];
-							}	
+							for (j = i; grp->gr_mem[j] != NULL; j++)
+								grp->gr_mem[j] = grp->gr_mem[j+1];
 							strlcpy(group, grp->gr_name, MAXLOGNAME);
 							chggrent(group, grp);
 						}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406271851.s5RIpJfa042581>