1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-16390: dba_open() can segfault for "pathless" streams
This commit is contained in:
Christoph M. Becker
2024-10-21 00:22:52 +02:00
3 changed files with 23 additions and 6 deletions

3
NEWS
View File

@@ -22,6 +22,9 @@ PHP NEWS
. Fixed bug GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset).
(cmb)
- DBA:
. Fixed bug GH-16390 (dba_open() can segfault for "pathless" streams). (cmb)
- DOM:
. Fixed bug GH-16316 (DOMXPath breaks when not initialized properly).
(nielsdos)

View File

@@ -788,10 +788,13 @@ restart:
info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path);
if (info->lock.fp) {
if (is_db_lock) {
ZEND_ASSERT(opened_path);
/* replace the path info with the real path of the opened file */
zend_string_release(info->path);
info->path = php_dba_zend_string_dup_safe(opened_path, persistent);
if (opened_path) {
/* replace the path info with the real path of the opened file */
zend_string_release_ex(info->path, persistent);
info->path = php_dba_zend_string_dup_safe(opened_path, persistent);
} else {
error = "Unable to determine path for locking";
}
}
}
if (opened_path) {
@@ -807,10 +810,10 @@ restart:
FREE_PERSISTENT_RESOURCE_KEY();
RETURN_FALSE;
}
if (!php_stream_supports_lock(info->lock.fp)) {
if (!error && !php_stream_supports_lock(info->lock.fp)) {
error = "Stream does not support locking";
}
if (php_stream_lock(info->lock.fp, lock_mode)) {
if (!error && php_stream_lock(info->lock.fp, lock_mode)) {
error = "Unable to establish lock"; /* force failure exit */
}
}

View File

@@ -0,0 +1,11 @@
--TEST--
GH-16390 (dba_open() can segfault for "pathless" streams)
--EXTENSIONS--
dba
--FILE--
<?php
$file = 'data:text/plain;z=y;uri=eviluri;mediatype=wut?;mediatype2=hello,somedata';
$db = dba_open($file, 'c', 'inifile');
?>
--EXPECTF--
Warning: dba_open(): Driver initialization failed for handler: inifile: Unable to determine path for locking in %s on line %d