From 4ca6bde32fcb3d32e57b7a976189a7bd0954a941 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Tue, 11 Mar 2025 12:08:53 +0100 Subject: [PATCH 1/2] Fix bug and add test for dba_open same file twice (#17979) Co-authored-by: Christian Schneider --- ext/dba/dba.c | 3 ++- ext/dba/tests/dba_duplicateopen.phpt | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ext/dba/tests/dba_duplicateopen.phpt diff --git a/ext/dba/dba.c b/ext/dba/dba.c index e4986e1cd23..2205b13dfe0 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -57,6 +57,7 @@ ZEND_BEGIN_MODULE_GLOBALS(dba) const char *default_handler; const dba_handler *default_hptr; HashTable connections; + unsigned int connection_counter; ZEND_END_MODULE_GLOBALS(dba) ZEND_DECLARE_MODULE_GLOBALS(dba) @@ -571,7 +572,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) char *resource_key; size_t resource_key_len = spprintf(&resource_key, 0, - "dba_%d_%s_%s_%s", persistent, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : "" + "dba_%d_%u_%s_%s_%s", persistent, persistent ? 0 : DBA_G(connection_counter)++, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : "" ); if (persistent) { diff --git a/ext/dba/tests/dba_duplicateopen.phpt b/ext/dba/tests/dba_duplicateopen.phpt new file mode 100644 index 00000000000..7068981f1a3 --- /dev/null +++ b/ext/dba/tests/dba_duplicateopen.phpt @@ -0,0 +1,34 @@ +--TEST-- +DBA open same read only file multiple times +--EXTENSIONS-- +dba +--SKIPIF-- + +--CONFLICTS-- +test.cdb +--FILE-- + +--EXPECT-- +database handler: cdb +1122 From bb4174e6bcb72d781d2438a4b7e946ee6e2590b9 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 11 Mar 2025 11:10:19 +0000 Subject: [PATCH 2/2] [skip ci] Update NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 88b34353d5a..9a356c3c637 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS . Fixed bug GH-17998 (Assignment to backing value in set hook of lazy proxy calls hook again). (ilutov) +- DBA: + . Fixed assertion violation when opening the same file with dba_open + multiple times. (chschneider) + - DOM: . Fixed bug GH-17991 (Assertion failure dom_attr_value_write). (nielsdos) . Fix weird unpack behaviour in DOM. (nielsdos)