diff options
author | jamie <jamie@FreeBSD.org> | 2015-12-18 00:33:04 +0000 |
---|---|---|
committer | jamie <jamie@FreeBSD.org> | 2015-12-18 00:33:04 +0000 |
commit | cb15359712d2ef7a5d75c3f9e521bd5c9ce1d329 (patch) | |
tree | e51fb0d73f5f2a2d90a9ab5aea349d180a65d910 | |
parent | 9e838a130f7515d8e377b7627d6a42db0e14158f (diff) | |
download | FreeBSD-src-cb15359712d2ef7a5d75c3f9e521bd5c9ce1d329.zip FreeBSD-src-cb15359712d2ef7a5d75c3f9e521bd5c9ce1d329.tar.gz |
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
-rw-r--r-- | sys/kern/kern_jail.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index af5feb3..42c53c0 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1585,11 +1585,14 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) #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)"); |