[php-src] PR #25674: ext/bz2: Fix NULL dereference when compress.bzip2:// open fails in write mode
| From: | Schwarzemann | Date: | Mon, 23 Nov 2026 14:34:17 +0000 |
| Subject: | [php-src] PR #25674: ext/bz2: Fix NULL dereference when compress.bzip2:// open fails in write mode | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40927@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25674
Author: Schwarzemann
When
BZ2_bzopen() fails, _php_stream_bz2open() falls back to
php_stream_open_wrapper(). If that also fails, *opened_path is NULL,
but the write-mode cleanup still calls VCWD_UNLINK(ZSTR_VAL(*opened_path)).
Reproducer:
dba_open("compress.bzip2:///nonexistent-dir/x", "nd", "flatfile");
- ZTS: segfault in virtual_unlink().
- NTS: unlink(0x18) fails with EFAULT, no crash.
Fix: also check *opened_path before unlinking.
Test: ext/bz2/tests/dba_opened_path_null.phpt. It needs bz2 and dba,
and crashes without the fix on ZTS builds.