From 68f6498bd3ec2442ec9952072986dce92f5cd9d3 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 10 Jul 2024 15:07:27 +0200 Subject: [PATCH] Only read first 500 bytes of a bin file to detect if it is a PHP script, refs #12032 --- src/Composer/Installer/BinaryInstaller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 9e3123ff8..3e67ef486 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -213,7 +213,7 @@ class BinaryInstaller $binDir = ProcessExecutor::escape(dirname($binPath)); $binFile = basename($binPath); - $binContents = file_get_contents($bin); + $binContents = file_get_contents($bin, false, null, 0, 500); // For php files, we generate a PHP proxy instead of a shell one, // which allows calling the proxy with a custom php process if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {