diff --git a/NEWS b/NEWS index fb54e6dd3e6c..e63ecbc464bb 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-24641 (ndbm handler does not check dbm_open() result). + (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_ndbm.c b/ext/dba/dba_ndbm.c index 40ae304cb7d2..58e4893ec2d2 100644 --- a/ext/dba/dba_ndbm.c +++ b/ext/dba/dba_ndbm.c @@ -53,6 +53,9 @@ DBA_OPEN_FUNC(ndbm) } dbf = dbm_open(ZSTR_VAL(info->path), gmode, filemode); + if (dbf == NULL) { + return FAILURE; + } pinfo->dbf = dbf; return SUCCESS; diff --git a/ext/dba/tests/gh24641.phpt b/ext/dba/tests/gh24641.phpt new file mode 100644 index 000000000000..8047654fec92 --- /dev/null +++ b/ext/dba/tests/gh24641.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-24641 (ndbm handler does not check dbm_open() result) +--EXTENSIONS-- +dba +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Warning: dba_open(): Driver initialization failed for handler: ndbm in %s on line %d +bool(false)