1
0
Fork 0

Validate the integrity of the downloaded phar before overwriting

pull/577/head
H. Westphal 2012-04-14 16:14:08 +02:00
parent 5a3827cefb
commit 397fa05c5b
1 changed files with 10 additions and 1 deletions

View File

@ -48,8 +48,17 @@ EOT
$remoteFilename = 'http://getcomposer.org/composer.phar'; $remoteFilename = 'http://getcomposer.org/composer.phar';
$localFilename = $_SERVER['argv'][0]; $localFilename = $_SERVER['argv'][0];
$tempFilename = $localFilename.'temp';
$rfs->copy('getcomposer.org', $remoteFilename, $localFilename); $rfs->copy('getcomposer.org', $remoteFilename, $tempFilename);
try {
$phar = new \Phar($tempFilename);
rename($tempFilename, $localFilename);
} catch (\UnexpectedValueException $e) {
unlink($tempFilename);
$output->writeln("<error>The download is corrupt. Please re-run the self-update command.</error>");
}
} else { } else {
$output->writeln("<info>You are using the latest composer version.</info>"); $output->writeln("<info>You are using the latest composer version.</info>");
} }