-
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.
Fixed bug #75111 (Memory disclosure or DoS via crafted .bmp image)
Crafted BMP images can cause dynamicSeek() to be called with a negative position which must not be allowed, since dynamicSeek() works like fseek() in SEEK_SET mode. We solve this by bailing out if `pos` is negative, and let the image reading fail gracefully.
- Loading branch information
Showing
4 changed files
with
43 additions
and
4 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
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,25 @@ | ||
--TEST-- | ||
Bug #75111 (Memory disclosure or DoS via crafted .bmp image) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('gd')) die('skip gd extension not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
// craft BMP image | ||
$str = hex2bin("424D3603000000000000"); | ||
$str .= pack("V", -0x120000); // offset of image data | ||
$str .= pack("V", 40); // length of header | ||
$str .= pack("V", 256); // width | ||
$str .= pack("V", 256); // height | ||
$str .= hex2bin("01001800000000000000000000000000000000000000000000000000"); | ||
|
||
var_dump(imagecreatefromstring($str)); | ||
?> | ||
===DONE=== | ||
--EXPECTF-- | ||
Warning: imagecreatefromstring(): Passed data is not in 'BMP' format in %s on line %d | ||
|
||
Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in %s on line %d | ||
bool(false) | ||
===DONE=== |