svn commit: r244720 - head/usr.sbin/pw

Baptiste Daroussin bapt at FreeBSD.org
Wed Dec 26 23:14:34 UTC 2012


Author: bapt
Date: Wed Dec 26 23:14:33 2012
New Revision: 244720
URL: http://svnweb.freebsd.org/changeset/base/244720

Log:
  Fix off-by-one error in memory allocation: j entries, one new and a null
  terminator is j + 2.
  
  Submitted by:	Christoph Mallon <christoph.mallon at gmx.de>

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

Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c	Wed Dec 26 22:21:27 2012	(r244719)
+++ head/usr.sbin/pw/pw_user.c	Wed Dec 26 23:14:33 2012	(r244720)
@@ -756,7 +756,7 @@ pw_user(struct userconf * cnf, int mode,
 			if (grp->gr_mem[j] != NULL) /* user already member of group */
 				continue;
 
-			members = malloc(sizeof(char *) * (j + 1));
+			members = malloc(sizeof(char *) * (j + 2));
 			for (j = 0; grp->gr_mem[j] != NULL; j++)
 				members[j] = grp->gr_mem[j];
 


More information about the svn-src-head mailing list