Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion ext/dba/dba_tcadb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 24 additions & 0 deletions ext/dba/tests/gh24640.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
GH-24640 (tcadb handler allows injecting Tokyo Cabinet parameters via "#" in the path)
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('tcadb');
?>
--FILE--
<?php
$db_file = __DIR__ . '/gh24640.tch';

var_dump(dba_open($db_file . '#bnum=1000', 'n-', 'tcadb'));
var_dump(file_exists($db_file));
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/gh24640.tch');
?>
--EXPECTF--
Warning: dba_open(): Driver initialization failed for handler: tcadb: Path must not contain "#" in %s on line %d
bool(false)
bool(false)
Loading