File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ PHP NEWS
23
23
(Nikita)
24
24
. Fixed bug #79784 (Use after free if changing array during undef var during
25
25
array write fetch). (Nikita)
26
+ . Fixed bug #79793 (Use after free if string used in undefined index warning
27
+ is changed). (Nikita)
26
28
27
29
- Fileinfo:
28
30
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #79793: Use after free if string used in undefined index warning is changed
3
+ --FILE--
4
+ <?php
5
+
6
+ $ key = "foo " ;
7
+ $ key .= "bar " ;
8
+ set_error_handler (function ($ _ , $ m ) use (&$ key ) {
9
+ echo "$ m \n" ;
10
+ $ key .= "baz " ;
11
+ });
12
+
13
+ $ ary = [];
14
+ $ ary [$ key ]++;
15
+ var_dump ($ ary );
16
+ $ ary [$ key ] += 1 ;
17
+ var_dump ($ ary );
18
+
19
+ ?>
20
+ --EXPECT--
21
+ Undefined index: foobar
22
+ array(1) {
23
+ ["foobar"]=>
24
+ int(1)
25
+ }
26
+ Undefined index: foobarbaz
27
+ array(2) {
28
+ ["foobar"]=>
29
+ int(1)
30
+ ["foobarbaz"]=>
31
+ int(1)
32
+ }
Original file line number Diff line number Diff line change @@ -2181,10 +2181,15 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
2181
2181
retval = & EG (uninitialized_zval );
2182
2182
break ;
2183
2183
case BP_VAR_RW :
2184
+ /* Key may be released while throwing the undefined index warning. */
2185
+ zend_string_addref (offset_key );
2184
2186
if (UNEXPECTED (zend_undefined_index_write (ht , offset_key ) == FAILURE )) {
2187
+ zend_string_release (offset_key );
2185
2188
return NULL ;
2186
2189
}
2187
- /* break missing intentionally */
2190
+ retval = zend_hash_add_new (ht , offset_key , & EG (uninitialized_zval ));
2191
+ zend_string_release (offset_key );
2192
+ break ;
2188
2193
case BP_VAR_W :
2189
2194
retval = zend_hash_add_new (ht , offset_key , & EG (uninitialized_zval ));
2190
2195
break ;
You can’t perform that action at this time.
0 commit comments