Skip to content

Commit c83a10d

Browse files
AyeshGirgias
authored andcommitted
[run-tests.php] Replace backtick operator string literals with shell_exec() calls
The rationale is that `shell_exec()` is identical to the backtick operator (both of which are disabled when `shell_exec` function is disabled) makes it very clear that it is a shell execution, and eases security audits too.
1 parent f958701 commit c83a10d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

run-tests.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -843,19 +843,19 @@ function write_information(): void
843843
$info_params = [];
844844
settings2array($ini_overwrites, $info_params);
845845
$info_params = settings2params($info_params);
846-
$php_info = `$php $pass_options $info_params $no_file_cache "$info_file"`;
847-
define('TESTED_PHP_VERSION', `$php -n -r "echo PHP_VERSION;"`);
846+
$php_info = shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"");
847+
define('TESTED_PHP_VERSION', shell_exec("$php -n -r \"echo PHP_VERSION;\""));
848848

849849
if ($php_cgi && $php != $php_cgi) {
850-
$php_info_cgi = `$php_cgi $pass_options $info_params $no_file_cache -q "$info_file"`;
850+
$php_info_cgi = shell_exec("$php_cgi $pass_options $info_params $no_file_cache -q \"$info_file\"");
851851
$php_info_sep = "\n---------------------------------------------------------------------";
852852
$php_cgi_info = "$php_info_sep\nPHP : $php_cgi $php_info_cgi$php_info_sep";
853853
} else {
854854
$php_cgi_info = '';
855855
}
856856

857857
if ($phpdbg) {
858-
$phpdbg_info = `$phpdbg $pass_options $info_params $no_file_cache -qrr "$info_file"`;
858+
$phpdbg_info = shell_exec("$phpdbg $pass_options $info_params $no_file_cache -qrr \"$info_file\"");
859859
$php_info_sep = "\n---------------------------------------------------------------------";
860860
$phpdbg_info = "$php_info_sep\nPHP : $phpdbg $phpdbg_info$php_info_sep";
861861
} else {
@@ -883,7 +883,7 @@ function write_information(): void
883883
}
884884
?>
885885
PHP);
886-
$exts_to_test = explode(',', `$php $pass_options $info_params $no_file_cache "$info_file"`);
886+
$exts_to_test = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""));
887887
// check for extensions that need special handling and regenerate
888888
$info_params_ex = [
889889
'session' => ['session.auto_start=0'],
@@ -3652,8 +3652,8 @@ public function getExtensions(string $php): array
36523652
return $this->extensions[$php];
36533653
}
36543654

3655-
$extDir = `$php -d display_errors=0 -r "echo ini_get('extension_dir');"`;
3656-
$extensions = explode(",", `$php -d display_errors=0 -r "echo implode(',', get_loaded_extensions());"`);
3655+
$extDir = shell_exec("$php -d display_errors=0 -r \"echo ini_get('extension_dir');\"");
3656+
$extensions = explode(",", shell_exec("$php -d display_errors=0 -r \"echo implode(',', get_loaded_extensions());\""));
36573657
$extensions = array_map('strtolower', $extensions);
36583658
if (in_array('zend opcache', $extensions)) {
36593659
$extensions[] = 'opcache';

0 commit comments

Comments
 (0)