[php-src] PR #17979: Fix bug and add test for dba_open same file twice
| From: | chschneider | Date: | Wed, 05 Mar 2025 20:13:18 +0000 |
| Subject: | [php-src] PR #17979: Fix bug and add test for dba_open same file twice | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30977@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17979
Author: chschneider
When doing dba_open twice with the same file then dba_open tries to insert the same key into its
hash table which triggers an assertion in a debug build and causes memory corruption in production.
A small reproduction script is
```php
<?php
$a = dba_open("ext/dba/tests/test.cdb", "r");
$b = dba_open("ext/dba/tests/test.cdb", "r");
var_dump($a, $b);
```
The solution I chose is to add a counter to the keys generated with dba_open (but no dba_popen) to
avoid key collisions.