You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ext/dba: ndbm backend never checks dbm_open() return value, NULL deref on first use after a failed open #24641
ndbm is the only one that skips it, so info->dbf ends up NULL while dba_open() still reports success. Any subsequent operation (dba_firstkey, dba_fetch, etc.) calls directly into the NDBM library with a NULL handle.
Repro:
<?phpfile_put_contents('/tmp/invalid_ndbm_file', 'not a valid ndbm/gdbm database, just plain text');
$db = dba_open('/tmp/invalid_ndbm_file', 'r', 'ndbm');
var_dump($db); // truthy -- reports SUCCESS despite the invalid formatdba_firstkey($db); // SEGV
Address 0x000000000000 confirms a plain NULL-pointer dereference.
Built/tested with --enable-dba --with-ndbm (Ubuntu libgdbm-compat-dev, CFLAGS="-fsanitize=address -g -O0").
Note on reachability: PHP's own generic dispatcher (ext/dba/dba.c, php_stream_open_wrapper()) already blocks a path that doesn't exist at all before it reaches the ndbm handler. This crash needs the path to already exist as a real file, just not a valid NDBM/GDBM database — an ordinary real-world state (wrong file, corrupted cache), not something requiring deliberate construction.
Suggested fix: add the same if (!dbf) return FAILURE; check ndbm's sibling backends already have.
Activity
dba: fix phpGH-24641 (NULL dereferencement with ndbm backend)
Merge branch 'PHP-8.4' into PHP-8.5
Merge branch 'PHP-8.5' into PHP-8.6
Merge branch 'PHP-8.6'
kunwaratulhax0r commentedon Oct 27, 2026
Thanks Team.