Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -19,6 +19,10 @@ PHP NEWS
- Curl:
. Fix various memory leaks in curl mime handling. (nielsdos)

- DBA:
. Fixed bug GH-16990 (dba_list() is now zero-indexed instead of using
resource ids) (kocsismate)

- DOM:
. Fixed bug GH-16906 (Reloading document can cause UAF in iterator).
(nielsdos)
Expand Down
6 changes: 3 additions & 3 deletions ext/dba/dba.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,9 +1293,9 @@ PHP_FUNCTION(dba_list)

zval *zv;
ZEND_HASH_MAP_FOREACH_VAL(&DBA_G(connections), zv) {
dba_info *info = Z_DBA_INFO_P(zv);
if (info) {
add_next_index_str(return_value, zend_string_copy(info->path));
dba_connection *connection = Z_DBA_CONNECTION_P(zv);
if (connection->info) {
add_index_str(return_value, connection->std.handle, zend_string_copy(connection->info->path));
}
} ZEND_HASH_FOREACH_END();
}
Expand Down
46 changes: 46 additions & 0 deletions ext/dba/tests/gh16990.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--TEST--
GH-16990 (dba_list() is now zero-indexed instead of using resource ids)
--EXTENSIONS--
dba
--CONFLICTS--
dba
--SKIPIF--
<?php
$handler = "flatfile";
require_once(__DIR__ .'/skipif.inc');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out!

?>
--FILE--
<?php

require_once(__DIR__ .'/test.inc');

$foo1 = new stdClass();

$db_filename1 = __DIR__.'/test1.dbm';
$db1 = dba_open($db_filename1, 'c', 'flatfile');
if (!$db1) {
var_dump("Database file creation failed");
}

$foo2 = new stdClass();

$db_filename2 = __DIR__.'/test2.dbm';
$db2 = dba_open($db_filename2, 'c', 'flatfile');
if (!$db2) {
var_dump("Database file creation failed");
}

var_dump(dba_list());
?>
--CLEAN--
<?php
@unlink(__DIR__.'/test1.dbm');
@unlink(__DIR__.'/test2.dbm');
?>
--EXPECTF--
array(2) {
[2]=>
string(%d) "%s%etest1.dbm"
[4]=>
string(%d) "%s%etest2.dbm"
}