TT#75114 prevent exit() invocations

Change-Id: If6c1049b842b44706c076e9e39ee7d42de4a43b5
changes/01/37201/4
Rene Krenn 6 years ago
parent d9a4d49ab5
commit 193e305fa5

@ -28,6 +28,19 @@ use NGCP::Panel::Utils::Subscriber qw();
use NGCP::Panel::Utils::Preferences qw(); use NGCP::Panel::Utils::Preferences qw();
use NGCP::Panel::Utils::Kamailio qw(); use NGCP::Panel::Utils::Kamailio qw();
#The function _calculate() evaluates perl code provided via a configuration
#by the user, so we must make sure no such code will call exit() by
#accident or we would terminate the entire program.
our $DISABLE_EXIT = 0;
BEGIN {
*CORE::GLOBAL::exit = sub (;$) {
## no critic (TestingAndDebugging::ProhibitNoWarnings)
no warnings 'exiting';
die('exit() called') if $DISABLE_EXIT;
CORE::exit($_[0] // 0);
};
}
my $IDENTIFIER_FNAME = 'identifier'; my $IDENTIFIER_FNAME = 'identifier';
my $CODE_SUFFIX_FNAME = '_code'; my $CODE_SUFFIX_FNAME = '_code';
my $FIELD_TYPE_ATTRIBUTE = 'type'; my $FIELD_TYPE_ATTRIBUTE = 'type';
@ -997,6 +1010,7 @@ sub _calculate {
$context->{cr_c} //= {}; $context->{cr_c} //= {};
if ($f =~ /^([a-z0-9_]+)$CODE_SUFFIX_FNAME$/) { if ($f =~ /^([a-z0-9_]+)$CODE_SUFFIX_FNAME$/) {
my $cl; my $cl;
local $DISABLE_EXIT = 1;
if ($strict_closure) { if ($strict_closure) {
$cl = eval_closure( $cl = eval_closure(
source => $c, source => $c,

Loading…
Cancel
Save