Date: Fri, 4 Sep 2020 00:22:25 +0000 (UTC) From: Jamie Gritton <jamie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r365320 - stable/12/usr.sbin/jail Message-ID: <202009040022.0840MPOU029438@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jamie Date: Fri Sep 4 00:22:24 2020 New Revision: 365320 URL: https://svnweb.freebsd.org/changeset/base/365320 Log: MFC r364850: Don't allow jail.conf variables to have the same names as jail parameters. It was already not allowed in many cases, but crashed instead of giving an error. PR: 248444 Modified: stable/12/usr.sbin/jail/config.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/jail/config.c ============================================================================== --- stable/12/usr.sbin/jail/config.c Fri Sep 4 00:12:28 2020 (r365319) +++ stable/12/usr.sbin/jail/config.c Fri Sep 4 00:22:24 2020 (r365320) @@ -366,8 +366,13 @@ add_param(struct cfjail *j, const struct cfparam *p, e break; if (dp != NULL) { /* Found it - append or replace. */ + if ((flags ^ dp->flags) & PF_VAR) { + jail_warnx(j, "variable \"$%s\" cannot have the same " + "name as a parameter.", name); + return; + } if (dp->flags & PF_IMMUTABLE) { - jail_warnx(j, "cannot redefine variable \"%s\".", + jail_warnx(j, "cannot redefine parameter \"%s\".", dp->name); return; } @@ -394,6 +399,14 @@ add_param(struct cfjail *j, const struct cfparam *p, e for (ipnum = IP__NULL + 1; ipnum < IP_NPARAM; ipnum++) if (!(intparams[ipnum].flags & PF_CONV) && equalopts(name, intparams[ipnum].name)) { + if (flags & PF_VAR) { + jail_warnx(j, + "variable \"$%s\" " + "cannot have the same " + "name as a parameter.", + name); + return; + } j->intparams[ipnum] = np; np->flags |= intparams[ipnum].flags; break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009040022.0840MPOU029438>