[php-src] PR #19710: Fix GH-19706: dba stream resource mismanagement
| From: | nielsdos | Date: | Thu, 04 Sep 2025 18:48:08 +0000 |
| Subject: | [php-src] PR #19710: Fix GH-19706: dba stream resource mismanagement | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33077@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19710
Author: nielsdos
This regressed in 8.4 when dba started mixing objects and resources (streams).
The streams are first destroyed at a first step in shutdown, and in slow shutdown then the symbol
table is destroyed which destroys the dba objects. The dba objects still use the streams but they
have been destroyed already, causing a UAF. Using dtor_obj instead of free_obj would work around
this but would cause issues like memory leaks because dtor_obj may be skipped while free_obj may not
be. Instead, use the same solution as mysqlnd uses in that we fully manage the stream lifecycle
ourselves. This also avoids users from meddling with the stream through get_resources().
This would be fixed 'automatically' in the future when we are using objects for
everything.