[Midnightbsd-cvs] src [7501] trunk/sys/kern/kern_jail.c: Fix jail name checking that disallowed anything that starts with '0'.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Apr 3 11:48:51 EDT 2016
Revision: 7501
http://svnweb.midnightbsd.org/src/?rev=7501
Author: laffer1
Date: 2016-04-03 11:46:50 -0400 (Sun, 03 Apr 2016)
Log Message:
-----------
Fix jail name checking that disallowed anything that starts with '0'. The intention was to just limit leading zeros on numeric names. That check is now imporved to allow catching the leading spaces and + that strtoul can pass through.
Obained from: FreeBSD rev 292277
Revision Links:
--------------
http://svnweb.midnightbsd.org/src/?rev=292277
Modified Paths:
--------------
trunk/sys/kern/kern_jail.c
Modified: trunk/sys/kern/kern_jail.c
===================================================================
--- trunk/sys/kern/kern_jail.c 2016-03-25 01:08:06 UTC (rev 7500)
+++ trunk/sys/kern/kern_jail.c 2016-04-03 15:46:50 UTC (rev 7501)
@@ -1526,11 +1526,14 @@
#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 Midnightbsd-cvs
mailing list