mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-24 00:23:28 +01:00
Avoid a call to eval() for simple expressions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
e9d8228b6f
commit
83df8a4e39
@ -1708,11 +1708,23 @@ sub evaluate_expression( $$$ ) {
|
|||||||
$expression = join( '', $first, $val, $rest );
|
$expression = join( '', $first, $val, $rest );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $val = eval qq(package Shorewall::User;\nuse strict;\n# line $linenumber "$filename"\n$expression);
|
my $val;
|
||||||
|
|
||||||
unless ( $val ) {
|
if ( $expression =~ /^\s*(\d+)\s*$/ || $expression =~ /\s*'(.*?)'\s*$/ ) {
|
||||||
cond_error( "Couldn't parse expression: $@" , $filename, $linenumber ) if $@;
|
#
|
||||||
cond_error( "Undefined expression" , $filename, $linenumber ) unless defined $val;
|
# Simple one-term expression -- don't compile it
|
||||||
|
#
|
||||||
|
$val = $1;
|
||||||
|
} else {
|
||||||
|
#
|
||||||
|
# Not a simple one-term expression
|
||||||
|
#
|
||||||
|
$val = eval qq(package Shorewall::User;\nuse strict;\n# line $linenumber "$filename"\n$expression);
|
||||||
|
|
||||||
|
unless ( $val ) {
|
||||||
|
cond_error( "Couldn't parse expression: $@" , $filename, $linenumber ) if $@;
|
||||||
|
cond_error( "Undefined expression" , $filename, $linenumber ) unless defined $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$val;
|
$val;
|
||||||
|
Loading…
Reference in New Issue
Block a user