Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carefully crafted ICO can trigger a fatal error #22

Open
offsky opened this issue Mar 27, 2024 · 1 comment
Open

Carefully crafted ICO can trigger a fatal error #22

offsky opened this issue Mar 27, 2024 · 1 comment

Comments

@offsky
Copy link

offsky commented Mar 27, 2024

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

@lordelph
Copy link
Owner

Thanks for this - I'll try and incorporate this into a new release in next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants