Skip to content

Commit e63f7b4

Browse files
committed
Merge branch 'bug68710' into PHP-5.4
* bug68710: Fix for bug #68710 (Use After Free Vulnerability in PHP's unserialize())
2 parents fc6aa93 + b585a3a commit e63f7b4

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 20?? PHP 5.4.37
4+
- Core:
5+
. Fixed bug #68710 (Use After Free Vulnerability in PHP's unserialize()).
6+
(CVE-2015-0231) (Stefan Esser)
7+
48
- CGI:
59
. Fixed bug #68618 (out of bounds read crashes php-cgi). (Stas)
610

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #68710 Use after free vulnerability in unserialize() (bypassing the
3+
CVE-2014-8142 fix)
4+
--FILE--
5+
<?php
6+
for ($i=4; $i<100; $i++) {
7+
$m = new StdClass();
8+
9+
$u = array(1);
10+
11+
$m->aaa = array(1,2,&$u,4,5);
12+
$m->bbb = 1;
13+
$m->ccc = &$u;
14+
$m->ddd = str_repeat("A", $i);
15+
16+
$z = serialize($m);
17+
$z = str_replace("aaa", "123", $z);
18+
$z = str_replace("bbb", "123", $z);
19+
$y = unserialize($z);
20+
$z = serialize($y);
21+
}
22+
?>
23+
===DONE===
24+
--EXPECTF--
25+
===DONE===

ext/standard/var_unserializer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */
1+
/* Generated by re2c 0.13.7.5 on Thu Jan 1 14:43:18 2015 */
22
#line 1 "ext/standard/var_unserializer.re"
33
/*
44
+----------------------------------------------------------------------+
@@ -343,7 +343,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
343343
} else {
344344
/* object properties should include no integers */
345345
convert_to_string(key);
346-
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
346+
if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
347347
var_push_dtor(var_hash, old_data);
348348
}
349349
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,

ext/standard/var_unserializer.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
347347
} else {
348348
/* object properties should include no integers */
349349
convert_to_string(key);
350-
if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
350+
if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
351351
var_push_dtor(var_hash, old_data);
352352
}
353353
zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,

0 commit comments

Comments
 (0)