mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Don't throw from imagecreatefromstring() with too short string
If the string is too short, we should treat this the same way as an unrecognized image type. This function should be usable to determine whether something is a valid image without doing any checks beforehand.
This commit is contained in:
parent
7a61984a2b
commit
a89aaf6c38
2 changed files with 6 additions and 4 deletions
|
@ -1483,8 +1483,9 @@ PHP_FUNCTION(imagecreatefromstring)
|
|||
}
|
||||
|
||||
if (ZSTR_LEN(data) < sizeof(sig)) {
|
||||
zend_argument_value_error(1, "cannot be empty");
|
||||
RETURN_THROWS();
|
||||
/* Handle this the same way as an unknown image type. */
|
||||
php_error_docref(NULL, E_WARNING, "Data is not in a recognized format");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
memcpy(sig, ZSTR_VAL(data), sizeof(sig));
|
||||
|
|
|
@ -62,6 +62,7 @@ $im = imagecreatefromstring(' asdf jklp foo');
|
|||
--EXPECTF--
|
||||
createfromstring truecolor png: ok
|
||||
createfromstring palette png: ok
|
||||
imagecreatefromstring(): Argument #1 ($data) cannot be empty
|
||||
|
||||
Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d
|
||||
Warning: imagecreatefromstring(): Data is not in a recognized format in %s on line %d
|
||||
|
||||
Warning: imagecreatefromstring(): Data is not in a recognized format in %s on line %d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue