svn commit: r202142 - projects/ngroups/sys/kern

Brooks Davis brooks at FreeBSD.org
Tue Jan 12 07:40:58 UTC 2010


Author: brooks
Date: Tue Jan 12 07:40:58 2010
New Revision: 202142
URL: http://svn.freebsd.org/changeset/base/202142

Log:
  Cap ngroups_max and (INT_MAX-1), any larger and we'll overflow the int
  counters.

Modified:
  projects/ngroups/sys/kern/subr_param.c

Modified: projects/ngroups/sys/kern/subr_param.c
==============================================================================
--- projects/ngroups/sys/kern/subr_param.c	Tue Jan 12 07:34:23 2010	(r202141)
+++ projects/ngroups/sys/kern/subr_param.c	Tue Jan 12 07:40:58 2010	(r202142)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_param.h"
 #include "opt_maxusers.h"
 
+#include <sys/limits.h>
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -232,12 +233,15 @@ init_param1(void)
 
 	/*
 	 * Let the administrator set {NGROUPS_MAX}, but disallow values
-	 * less than NGROUPS_MAX which would violate POSIX.1-2008.
+	 * less than NGROUPS_MAX which would violate POSIX.1-2008 or
+	 * greater than INT_MAX-1 which would result in overflow.
 	 */
 	ngroups_max = NGROUPS_MAX;
 	TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
 	if (ngroups_max < NGROUPS_MAX)
 		ngroups_max = NGROUPS_MAX;
+	if (ngroups_max > INT_MAX - 1)
+		ngroups_max = INT_MAX - 1;
 }
 
 /*


More information about the svn-src-projects mailing list