mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Merge branch 'PHP-5.6' into PHP-7.0
This commit is contained in:
commit
436d50a821
@ -260,6 +260,16 @@ static PHP_FUNCTION(json_decode)
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
if (depth <= 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must be greater than zero");
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
if (depth > INT_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must be lower than %d", INT_MAX);
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
|
||||
if (assoc) {
|
||||
options |= PHP_JSON_OBJECT_AS_ARRAY;
|
||||
|
15
ext/json/tests/bug72787.phpt
Normal file
15
ext/json/tests/bug72787.phpt
Normal file
@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72787 (json_decode reads out of bounds)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("json")) print "skip"; ?>
|
||||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(json_decode('[]', false, 0x100000000));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Warning: json_decode(): Depth must be lower than %d in %s on line %d
|
||||
NULL
|
Loading…
Reference in New Issue
Block a user