svn commit: r292415 - stable/9/sys/kern

Jamie Gritton jamie at FreeBSD.org
Fri Dec 18 00:33:04 UTC 2015


Author: jamie
Date: Fri Dec 18 00:33:03 2015
New Revision: 292415
URL: https://svnweb.freebsd.org/changeset/base/292415

Log:
  MFC r292277:
  
    Fix jail name checking that disallowed anything that starts with '0'.
    The intention was to just limit leading zeroes on numeric names.  That
    check is now improved to also catch the leading spaces and '+' that
    strtoul can pass through.
  
  PR:		204897

Modified:
  stable/9/sys/kern/kern_jail.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_jail.c
==============================================================================
--- stable/9/sys/kern/kern_jail.c	Thu Dec 17 23:41:58 2015	(r292414)
+++ stable/9/sys/kern/kern_jail.c	Fri Dec 18 00:33:03 2015	(r292415)
@@ -1526,11 +1526,14 @@ kern_jail_set(struct thread *td, struct 
 #endif
 	onamelen = namelen = 0;
 	if (name != NULL) {
-		/* Give a default name of the jid. */
+		/* Give a default name of the jid.  Also allow the name to be
+		 * explicitly the jid - but not any other number, and only in
+		 * normal form (no leading zero/etc).
+		 */
 		if (name[0] == '\0')
 			snprintf(name = numbuf, sizeof(numbuf), "%d", jid);
-		else if (*namelc == '0' || (strtoul(namelc, &p, 10) != jid &&
-		    *p == '\0')) {
+		else if ((strtoul(namelc, &p, 10) != jid ||
+			  namelc[0] < '1' || namelc[0] > '9') && *p == '\0') {
 			error = EINVAL;
 			vfs_opterror(opts,
 			    "name cannot be numeric (unless it is the jid)");


More information about the svn-src-all mailing list