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
This commit is contained in:
parent
62cddd0e03
commit
bb4ec28922
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364850
@ -366,8 +366,13 @@ add_param(struct cfjail *j, const struct cfparam *p, enum intparam ipnum,
|
|||||||
break;
|
break;
|
||||||
if (dp != NULL) {
|
if (dp != NULL) {
|
||||||
/* Found it - append or replace. */
|
/* 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) {
|
if (dp->flags & PF_IMMUTABLE) {
|
||||||
jail_warnx(j, "cannot redefine variable \"%s\".",
|
jail_warnx(j, "cannot redefine parameter \"%s\".",
|
||||||
dp->name);
|
dp->name);
|
||||||
return;
|
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++)
|
for (ipnum = IP__NULL + 1; ipnum < IP_NPARAM; ipnum++)
|
||||||
if (!(intparams[ipnum].flags & PF_CONV) &&
|
if (!(intparams[ipnum].flags & PF_CONV) &&
|
||||||
equalopts(name, intparams[ipnum].name)) {
|
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;
|
j->intparams[ipnum] = np;
|
||||||
np->flags |= intparams[ipnum].flags;
|
np->flags |= intparams[ipnum].flags;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user