mirror of
https://github.com/php/php-src.git
synced 2026-10-28 17:56:50 +08:00
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5: dba: fix GH-24641 (NULL dereferencement with ndbm backend)
This commit is contained in:
3 files changed
+37
No files matched your search
@@ -6,6 +6,10 @@ PHP NEWS
|
||||
. Fix function and constant imports in compile_to_ast and add support
|
||||
for grouping. (Klaas Skelte van der Werf)
|
||||
|
||||
- DBA:
|
||||
. Fixed bug GH-24641 (ndbm backend never checks dbm_open() return value,
|
||||
NULL deref on first use after a failed open). (Girgias)
|
||||
|
||||
- Hash:
|
||||
. Fix GOST and Snefru digests of 512 MiB or more. (Martin Mirchev)
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ DBA_OPEN_FUNC(ndbm)
|
||||
}
|
||||
|
||||
dbf = dbm_open(ZSTR_VAL(info->path), gmode, filemode);
|
||||
if (dbf == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
pinfo->dbf = dbf;
|
||||
return SUCCESS;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
GH-24641 (ndbm backend never checks dbm_open() return value, NULL deref on first use after a failed open)
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
file_put_contents(__DIR__ . '/gh24641', 'not a valid ndbm/gdbm database, just plain text');
|
||||
|
||||
foreach (dba_handlers() as $handler) {
|
||||
/* Suppress warnings */
|
||||
$db = @dba_open(__DIR__ . '/gh24641', 'r', $handler);
|
||||
/* Expected as this file is not a proper db file */
|
||||
if ($db === false) {
|
||||
continue;
|
||||
}
|
||||
/* Some drivers just don't care */
|
||||
dba_firstkey($db); // SEGV
|
||||
dba_close($db);
|
||||
}
|
||||
|
||||
?>
|
||||
DONE
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(__DIR__ . '/gh24641');
|
||||
@unlink(__DIR__ . '/gh24641-lock');
|
||||
?>
|
||||
--EXPECT--
|
||||
DONE
|
||||
Reference in new issue
Block a user