From ca8d9f2b7ab5a32e5a6b5f43b79451f96e32b112 Mon Sep 17 00:00:00 2001 From: lazerg Date: Sat, 24 Oct 2026 21:14:38 +0500 Subject: [PATCH] Fix GH-24640: tcadb handler allows injecting Tokyo Cabinet parameters via "#" --- NEWS | 4 ++++ ext/dba/dba_tcadb.c | 9 ++++++++- ext/dba/tests/gh24640.phpt | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ext/dba/tests/gh24640.phpt diff --git a/NEWS b/NEWS index fb54e6dd3e6c..a85aecddf9b9 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,10 @@ PHP NEWS . Fixed bug GH-24350 (MINIT reads a stale external tz database after an in-process module restart). (Lazizbek Ergashev) +- DBA: + . Fixed bug GH-24640 (tcadb handler allows injecting Tokyo Cabinet + parameters via "#" in the path). (Lazizbek Ergashev) + - DOM: . Fixed bug GH-23352 (UAF reading an attribute value node retained across DOMDocument::adoptNode()). (David Carlier) diff --git a/ext/dba/dba_tcadb.c b/ext/dba/dba_tcadb.c index 6f4cb01e69e5..201fc73a2ad2 100644 --- a/ext/dba/dba_tcadb.c +++ b/ext/dba/dba_tcadb.c @@ -34,7 +34,14 @@ typedef struct { DBA_OPEN_FUNC(tcadb) { char *path_string; - TCADB *tcadb = tcadbnew(); + TCADB *tcadb; + + if (memchr(ZSTR_VAL(info->path), '#', ZSTR_LEN(info->path))) { + *error = "Path must not contain \"#\""; + return FAILURE; + } + + tcadb = tcadbnew(); if (tcadb) { switch(info->mode) { diff --git a/ext/dba/tests/gh24640.phpt b/ext/dba/tests/gh24640.phpt new file mode 100644 index 000000000000..6a7fce3d0c9c --- /dev/null +++ b/ext/dba/tests/gh24640.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-24640 (tcadb handler allows injecting Tokyo Cabinet parameters via "#" in the path) +--EXTENSIONS-- +dba +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Warning: dba_open(): Driver initialization failed for handler: tcadb: Path must not contain "#" in %s on line %d +bool(false) +bool(false)