Skip to content

Commit c26f0a8

Browse files
committed
Updated dependencies and prevent CVE-2023-43655
1 parent 767aa14 commit c26f0a8

File tree

3 files changed

+234
-214
lines changed

3 files changed

+234
-214
lines changed

api/console

+43-26
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* @license LGPL-3.0+
99
*/
1010

11+
if (0 === strpos(__FILE__, 'phar:') && ini_get('register_argc_argv')) {
12+
echo 'Contao Manager cannot be run safely on non-CLI SAPIs with register_argc_argv=On. Aborting.'.PHP_EOL;
13+
exit(1);
14+
}
15+
1116
setlocale(LC_ALL, 'C');
1217
require __DIR__.'/../vendor/autoload.php';
1318

@@ -29,38 +34,50 @@ if (function_exists('ini_set')) {
2934
@ini_set('display_errors', 1);
3035
@ini_set('zlib.output_compression', 0);
3136

32-
$memoryInBytes = static function ($value) {
33-
$unit = strtolower(substr($value, -1, 1));
34-
$value = (int) $value;
35-
switch($unit) {
36-
/** @noinspection PhpMissingBreakStatementInspection */
37-
case 'g':
38-
$value *= 1024;
39-
// no break (cumulative multiplier)
40-
/** @noinspection PhpMissingBreakStatementInspection */
41-
case 'm':
42-
$value *= 1024;
43-
// no break (cumulative multiplier)
44-
case 'k':
45-
$value *= 1024;
46-
}
47-
48-
return $value;
49-
};
50-
51-
$memoryLimit = trim(ini_get('memory_limit'));
52-
// Increase memory_limit if it is lower than 1.5GB
53-
if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
54-
@ini_set('memory_limit', '1536M');
55-
}
5637
// Set user defined memory limit
5738
if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
5839
@ini_set('memory_limit', $memoryLimit);
40+
} else {
41+
$memoryInBytes = static function ($value) {
42+
$unit = strtolower(substr($value, -1, 1));
43+
$value = (int) $value;
44+
switch($unit) {
45+
/** @noinspection PhpMissingBreakStatementInspection */
46+
case 'g':
47+
$value *= 1024;
48+
// no break (cumulative multiplier)
49+
/** @noinspection PhpMissingBreakStatementInspection */
50+
case 'm':
51+
$value *= 1024;
52+
// no break (cumulative multiplier)
53+
case 'k':
54+
$value *= 1024;
55+
}
56+
57+
return $value;
58+
};
59+
60+
$memoryLimit = trim(ini_get('memory_limit'));
61+
// Increase memory_limit if it is lower than 1.5GB
62+
if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
63+
@ini_set('memory_limit', '1536M');
64+
}
65+
unset($memoryInBytes);
66+
}
67+
unset($memoryLimit);
68+
}
69+
70+
// Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
71+
// see https://github.com/php/php-src/issues/7896
72+
if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
73+
foreach ($_SERVER as $serverVar => $serverVal) {
74+
if (($serverVal = getenv($serverVar)) !== false) {
75+
$_SERVER[$serverVar] = $serverVal;
76+
}
5977
}
60-
unset($memoryInBytes, $memoryLimit);
6178
}
6279

63-
putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
80+
Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
6481

6582
// Always create kernel to initialize the application
6683
$kernel = new ApiKernel('@symfony_env@' === 'prod' ? 'prod' : 'dev');

0 commit comments

Comments
 (0)