forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #73869: Signed Integer Overflow gd_io.c
GD2 stores the number of horizontal and vertical chunks as words (i.e. 2 byte unsigned). These values are multiplied and assigned to an int when reading the image, what can cause integer overflows. We have to avoid that, and also make sure that either chunk count is actually greater than zero. If illegal chunk counts are detected, we bail out from reading the image. (cherry picked from commit 5b5d9db3988b829e0b121b74bb3947f01c2796a1)
- Loading branch information
Showing
4 changed files
with
23 additions
and
0 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,19 @@ | ||
--TEST-- | ||
Bug #73869 (Signed Integer Overflow gd_io.c) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('gd')) die('skip gd extension not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2')); | ||
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2')); | ||
?> | ||
===DONE=== | ||
--EXPECTF-- | ||
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d | ||
bool(false) | ||
|
||
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d | ||
bool(false) | ||
===DONE=== |
Binary file not shown.
Binary file not shown.