[php-src] PR #21815: Fix GH-21639: Protect frameless implode args
| From: | prateekbhujel | Date: | Mon, 20 Apr 2026 05:32:29 +0000 |
| Subject: | [php-src] PR #21815: Fix GH-21639: Protect frameless implode args | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35795@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21815
Author: prateekbhujel
Fixes GH-21639.
The frameless implode handlers borrow their operand zvals directly. If string conversion re-enters
userland and clears the variables used for the separator or pieces, those borrowed values can be
released while php_implode() is still using them.
Copy the frameless arguments before parsing them so the one-argument and two-argument handlers keep
the same by-value lifetime guarantees as a normal call frame. The regression test covers mutation
from an array element, mutation during separator conversion, and the one-argument form.
Tests:
- ASAN build:
./configure --disable-all --enable-cli --enable-debug --without-pear
--enable-address-sanitizer
- run-tests.php -q ext/standard/tests/strings/gh21639.phpt
ext/standard/tests/strings/implode_basic.phpt ext/standard/tests/strings/implode_variation.phpt
ext/standard/tests/strings/join_basic.phpt