svn commit: r351258 - releng/11.3/sbin/ipfw
Gordon Tetlow
gordon at FreeBSD.org
Tue Aug 20 17:46:41 UTC 2019
Author: gordon
Date: Tue Aug 20 17:46:40 2019
New Revision: 351258
URL: https://svnweb.freebsd.org/changeset/base/351258
Log:
Fix ipfw(8) jail keyword prior to jail startup.
Approved by: so
Security: FreeBSD-EN-19:17.ipfw
Modified:
releng/11.3/sbin/ipfw/ipfw2.c
Modified: releng/11.3/sbin/ipfw/ipfw2.c
==============================================================================
--- releng/11.3/sbin/ipfw/ipfw2.c Tue Aug 20 17:46:22 2019 (r351257)
+++ releng/11.3/sbin/ipfw/ipfw2.c Tue Aug 20 17:46:40 2019 (r351258)
@@ -4662,12 +4662,27 @@ read_options:
case TOK_JAIL:
NEED1("jail requires argument");
{
+ char *end;
int jid;
cmd->opcode = O_JAIL;
- jid = jail_getid(*av);
- if (jid < 0)
- errx(EX_DATAERR, "%s", jail_errmsg);
+ /*
+ * If av is a number, then we'll just pass it as-is. If
+ * it's a name, try to resolve that to a jid.
+ *
+ * We save the jail_getid(3) call for a fallback because
+ * it entails an unconditional trip to the kernel to
+ * either validate a jid or resolve a name to a jid.
+ * This specific token doesn't currently require a
+ * jid to be an active jail, so we save a transition
+ * by simply using a number that we're given.
+ */
+ jid = strtoul(*av, &end, 10);
+ if (*end != '\0') {
+ jid = jail_getid(*av);
+ if (jid < 0)
+ errx(EX_DATAERR, "%s", jail_errmsg);
+ }
cmd32->d[0] = (uint32_t)jid;
cmd->len |= F_INSN_SIZE(ipfw_insn_u32);
av++;
More information about the svn-src-all
mailing list