-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #77270: imagecolormatch Out Of Bounds Write on Heap
At least some of the image reading functions may return images which use color indexes greater than or equal to im->colorsTotal. We cater to this by always using a buffer size which is sufficient for `gdMaxColors` in `gdImageColorMatch()`.
- Loading branch information
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
Bug #77270 (imagecolormatch Out Of Bounds Write on Heap) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('gd')) die('skip gd extension not available'); | ||
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream bugfix has not been released'); | ||
?> | ||
--FILE-- | ||
<?php | ||
$img1 = imagecreatetruecolor(0xfff, 0xfff); | ||
$img2 = imagecreate(0xfff, 0xfff); | ||
imagecolorallocate($img2, 0, 0, 0); | ||
imagesetpixel($img2, 0, 0, 255); | ||
imagecolormatch($img1, $img2); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |