Skip to content

Commit

Permalink
Fix bug #81265: getimagesize returns 0 for 256px ICO images
Browse files Browse the repository at this point in the history
Set ICO height/width to 256 if 0.
  • Loading branch information
Blacksmoke16 authored and nikic committed Jul 16, 2021
1 parent a054ef2 commit 8f97f82
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PHP NEWS

- Standard:
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)
. Fixed bug #81265 (getimagesize returns 0 for 256px ICO images).
(George Dietrich)

29 Jul 2021, PHP 7.4.22

Expand Down
6 changes: 6 additions & 0 deletions ext/standard/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,12 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
num_icons--;
}

if (0 == result->width)
result->width = 256;

if (0 == result->height)
result->height = 256;

return result;
}
/* }}} */
Expand Down
Binary file added ext/standard/tests/image/32x256.ico
Binary file not shown.
26 changes: 26 additions & 0 deletions ext/standard/tests/image/getimagesize_256_ico.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
GetImageSize() for ico format with 256px height
--FILE--
<?php
echo "*** Testing getimagesize() : 256px ico ***\n";
var_dump(getimagesize(__DIR__ . "/32x256.ico"));

?>
===DONE===
--EXPECT--
*** Testing getimagesize() : 256px ico ***
array(6) {
[0]=>
int(32)
[1]=>
int(256)
[2]=>
int(17)
[3]=>
string(23) "width="32" height="256""
["bits"]=>
int(8)
["mime"]=>
string(24) "image/vnd.microsoft.icon"
}
===DONE===

0 comments on commit 8f97f82

Please sign in to comment.