1
0
Fork 0

Merge pull request #577 from snc/issue574

Validate the integrity of the downloaded phar before overwriting
pull/575/merge
Jordi Boggiano 2012-04-14 10:21:53 -07:00
commit a46296e938
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>");
} }