Skip to content

Commit

Permalink
Update OptimizerChain.php
Browse files Browse the repository at this point in the history
Fix phar deserialization vulnerability
  • Loading branch information
Sonicrrrr committed Mar 6, 2024
1 parent f253738 commit 769e085
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/OptimizerChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@ public function useLogger(LoggerInterface $log)

public function optimize(string $pathToImage, string $pathToOutput = null)
{
/*
* Check $pathToImage before passing it into the copy() function.
*/
$image = new Image($pathToImage);
if ($pathToOutput) {
copy($pathToImage, $pathToOutput);

$pathToImage = $pathToOutput;
$check = copy($pathToImage, $pathToOutput);
if($check == false){
throw new InvalidArgumentException("Cannot copy file");
}
}

$image = new Image($pathToImage);
$this->logger->info("Start optimizing {$pathToImage}");

foreach ($this->optimizers as $optimizer) {
Expand Down

0 comments on commit 769e085

Please sign in to comment.