Skip to content

Commit

Permalink
Only allow PHP binaries of the same major.minor version
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Aug 12, 2024
1 parent 540c3ce commit 74a8c23
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions api/Process/PhpExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private function findExecutables(): array

private function findBestBinary(array $paths): ?string
{
$fallback = null;
$sapi = null;
$fallbackPath = null;
$fallbackSapi = null;

if ($openBasedir = \ini_get('open_basedir')) {
$openBasedir = explode(PATH_SEPARATOR, $openBasedir);
Expand Down Expand Up @@ -204,17 +204,18 @@ private function findBestBinary(array $paths): ?string
$vWeb = PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;
$vCli = vsprintf('%s.%s', explode('.', $info['version']));

// Allow fallback to another patch version of the same PHP major/minor
// and prefer a CLI SAPI over e.g. a CGI SAPI.
if (
null === $fallback || (
'cli' !== $sapi && 'cli' === $info['sapi'] && version_compare($vWeb, $vCli, 'eq')
)
(null === $fallbackPath || ('cli' !== $fallbackSapi && 'cli' === $info['sapi']))
&& version_compare($vWeb, $vCli, 'eq')
) {
$fallback = $path;
$sapi = $info['sapi'];
$fallbackPath = $path;
$fallbackSapi = $info['sapi'];
}
}

return $fallback;
return $fallbackPath;
}

/**
Expand Down

0 comments on commit 74a8c23

Please sign in to comment.