*PROPERLY* disable RUN in eval. :)

This commit is contained in:
Dianne Skoll
2025-05-23 12:03:09 -04:00
parent 4c2b6031cd
commit 7e5dc26ee5
3 changed files with 18 additions and 3 deletions

View File

@@ -3993,6 +3993,7 @@ FEval(func_info *info)
{
expr_node *n;
int r;
int run_was_enabled = 0;
ASSERT_TYPE(0, STR_TYPE);
char const *e = ARGSTR(0);
@@ -4004,9 +4005,14 @@ FEval(func_info *info)
}
/* Disable shell() command in eval */
RunDisabled |= RUN_IN_EVAL;
if (! (RunDisabled & RUN_IN_EVAL)) {
run_was_enabled = 1;
RunDisabled |= RUN_IN_EVAL;
}
r = evaluate_expr_node(n, NULL, &(info->retval), &(info->nonconst));
RunDisabled &= ~RUN_IN_EVAL;
if (run_was_enabled) {
RunDisabled &= ~RUN_IN_EVAL;
}
free_expr_tree(n);
return r;
}

View File

@@ -16542,11 +16542,18 @@ Entering UserFN i()
shell("echo foo") => "foo"
Leaving UserFN i() => "foo"
FUNSET i
set a "eval(\"1\")+ shell(\"ls\")"
set b eval(a)
a => "eval(\"1\")+ shell(\"ls\")"
eval("eval(\"1\")+ shell(\"ls\")") => eval("1") => 1
shell("ls") => RUN disabled
../tests/test.rem(1587): shell(): RUN disabled
RUN disabled
DEBUG -x
DEBUG -e
../tests/test.rem(1593): eval(): Too many recursive function calls
../tests/test.rem(1595): eval(): Too many recursive function calls
Base: 1991-02-09
Base: 1991-02-09
Variable hash table statistics:

View File

@@ -1583,6 +1583,8 @@ set a i()
set a eval("i()")
set a i()
FUNSET i
set a "eval(\"1\")+ shell(\"ls\")"
set b eval(a)
DEBUG -x