aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/jail
diff options
context:
space:
mode:
authorJamie Gritton <jamie@FreeBSD.org>2020-08-27 00:17:17 +0000
committerJamie Gritton <jamie@FreeBSD.org>2020-08-27 00:17:17 +0000
commitbb4ec289226d61a7b9551649f8c1359e5e285f5c (patch)
tree985c1cf2acd36c674210d895f87a97bb8f37d007 /usr.sbin/jail
parent62cddd0e033f7a4cbf460b0a8e61c34797073e16 (diff)
downloadsrc-bb4ec289226d61a7b9551649f8c1359e5e285f5c.tar.gz
src-bb4ec289226d61a7b9551649f8c1359e5e285f5c.zip
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
Notes
Notes: svn path=/head/; revision=364850
Diffstat (limited to 'usr.sbin/jail')
-rw-r--r--usr.sbin/jail/config.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c
index 234c4e257976..e81128ff1b93 100644
--- a/usr.sbin/jail/config.c
+++ b/usr.sbin/jail/config.c
@@ -366,8 +366,13 @@ add_param(struct cfjail *j, const struct cfparam *p, enum intparam ipnum,
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, enum intparam ipnum,
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;