com php-src: Fix bug #73029 - Missing type check when unserializing SplArray: ext/spl/spl_array.c ext/spl/tests/bug730 29.phpt

From: Date: Mon, 12 Sep 2016 15:42:23 +0000
Subject: com php-src: Fix bug #73029 - Missing type check when unserializing SplArray: ext/spl/spl_array.c ext/spl/tests/bug730 29.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94459@lists.php.net to get a copy of this message
Commit: 022e75cba104c52ccfb494ce224c2c4d0ff2dddc Author: Stanislav Malyshev <stas@php.net> Sun, 11 Sep 2016 20:24:13 -0700 Committer: Anatol Belski <ab@php.net> Mon, 12 Sep 2016 17:42:23 +0200 Parents: 060ab26cfe2f25bc59eb2de593e11cea84ef70b0 Branches: PHP-7.0.11 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=022e75cba104c52ccfb494ce224c2c4d0ff2dddc Log: Fix bug #73029 - Missing type check when unserializing SplArray (cherry picked from commit 6d16288150be33392a3249e417a0929881feb9a2) Conflicts: ext/spl/spl_array.c Bugs: https://bugs.php.net/73029 Changed paths: M ext/spl/spl_array.c A ext/spl/tests/bug73029.phpt Diff: diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 60cbac5..21f8403 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -295,7 +295,7 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object * zend_string *offset_key; HashTable *ht = spl_array_get_hash_table(intern); - if (!offset || Z_ISUNDEF_P(offset)) { + if (!offset || Z_ISUNDEF_P(offset) || !ht) { return &EG(uninitialized_zval); } @@ -1796,7 +1796,8 @@ SPL_METHOD(Array, unserialize) intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK; zval_ptr_dtor(&intern->array); ZVAL_UNDEF(&intern->array); - if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash)) { + if (!php_var_unserialize(&intern->array, &p, s + buf_len, &var_hash) + || (Z_TYPE(intern->array) != IS_ARRAY && Z_TYPE(intern->array) != IS_OBJECT)) { goto outexcept; } var_push_dtor(&var_hash, &intern->array); diff --git a/ext/spl/tests/bug73029.phpt b/ext/spl/tests/bug73029.phpt new file mode 100644 index 0000000..a379f80 --- /dev/null +++ b/ext/spl/tests/bug73029.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #73029: Missing type check when unserializing SplArray +--FILE-- +<?php +try { +$a = 'C:11:"ArrayObject":19:0x:i:0;r:2;;m:a:0:{}}'; +$m = unserialize($a); +$x = $m[2]; +} catch(UnexpectedValueException $e) { + print $e->getMessage() . "\n"; +} +?> +DONE +--EXPECTF-- +Error at offset 10 of 19 bytes +DONE

« previous php.cvs (#94459) next »