Commit 3e0bf4f
committed
deepclone_to_array: fix UAF on ref pointers across packed→hash conversion
dc_copy_array stashes pointers into dst's HT in ref_entry->tree_pos
for later dtor/replacement. But dst was initialized as an empty packed
HT, and the first add_new() on a string key triggers
zend_hash_packed_to_hash() — which frees the packed storage. Any
tree_pos saved by an earlier (integer-keyed) iteration from this array
now dangles, and the post-processing pass hits a heap-use-after-free
when dtoring through it.
Fix: force mixed/hash storage on dst and mask_dst before the loop, so
the first and all subsequent add_new() calls write into a stable
arData that won't be realloc'd out from under saved tree_pos pointers.
Found by libFuzzer (to_array round-trip harness + ASAN) — reproduced
with a 9-byte input that builds an array containing a ref and then
adds a string key via convert_to_string on a SplFixedArray key.1 parent 2603a8d commit 3e0bf4f
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
912 | 919 | | |
913 | 920 | | |
914 | 921 | | |
| |||
0 commit comments