Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,7 @@ PHP_FUNCTION(imagecreatefromstring)

if (ZSTR_LEN(data) > INT_MAX) {
zend_argument_value_error(1, "is too long");
RETURN_THROWS();
}

imtype = _php_image_type(data);
Expand Down
24 changes: 24 additions & 0 deletions ext/gd/tests/imagecreatefromstring_too_long.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
imagecreatefromstring(): a string longer than INT_MAX throws without decoding it
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--INI--
memory_limit=-1
--FILE--
<?php
$s = str_repeat("x", 2147483648);
try {
imagecreatefromstring($s);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "Done\n";
?>
--EXPECT--
imagecreatefromstring(): Argument #1 ($data) is too long
Done
Loading