icofileloader
icofileloader copied to clipboard
Carefully crafted ICO can trigger a fatal error
I ran into a situation with an ico image where IcoParser->isPNG($data)
passed, but then imagecreatefromstring($data)
failed. The result is that in parsePNGAsIco()
it crashes with a fatal error when it gets to the imagesx(false)
line. Here is the bug fix:
private function parsePNGAsIco($data)
{
$png = imagecreatefromstring($data);
+ if (!$png) {
+ throw new \InvalidArgumentException('Invalid PNG file format');
+ }
$w = imagesx($png);
$h = imagesy($png);
Here is the icon that triggered the error for me. favicon.ico.zip
Thanks for this - I'll try and incorporate this into a new release in next few days