1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 18:23:26 +02:00

Fixed bug #67539 (ArrayIterator use-after-free due to object change during sorting)

This commit is contained in:
Xinchen Hui
2014-07-02 17:57:42 +08:00
parent df78c48354
commit 22882a9d89
3 changed files with 24 additions and 0 deletions
+2
View File
@@ -22,6 +22,8 @@ PHP NEWS
which affected builds against libpq < 7.3. (Adam)
- SPL:
. Fixed bug #67539 (ArrayIterator use-after-free due to object change during
sorting). (research at insighti dot org, Laruence)
. Fixed bug #67538 (SPL Iterators use-after-free). (Laruence)
- Streams:
+7
View File
@@ -1733,6 +1733,7 @@ SPL_METHOD(Array, unserialize)
const unsigned char *p, *s;
php_unserialize_data_t var_hash;
zval *pmembers, *pflags = NULL;
HashTable *aht;
long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
@@ -1744,6 +1745,12 @@ SPL_METHOD(Array, unserialize)
return;
}
aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
if (aht->nApplyCount > 0) {
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
return;
}
/* storage */
s = p = (const unsigned char*)buf;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #67539 (ArrayIterator use-after-free due to object change during sorting)
--FILE--
<?php
$it = new ArrayIterator(array_fill(0,2,'X'), 1 );
function badsort($a, $b) {
$GLOBALS['it']->unserialize($GLOBALS['it']->serialize());
return TRUE;
}
$it->uksort('badsort');
--EXPECTF--
Warning: Modification of ArrayObject during sorting is prohibited in %sbug67539.php on line %d