1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

This commit is contained in:
David Carlier
2025-09-21 14:25:52 +01:00
2 changed files with 40 additions and 0 deletions

View File

@@ -1070,6 +1070,11 @@ PHP_FUNCTION(dba_fetch)
ZEND_PARSE_PARAMETERS_END();
}
if (ZEND_LONG_EXCEEDS_INT(skip)) {
zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX);
RETURN_THROWS();
}
info = Z_DBA_INFO_P(id);
CHECK_DBA_CONNECTION(info);

View File

@@ -0,0 +1,35 @@
--TEST--
GH-19885 (dba_fetch() segfault on large skip values)
--EXTENSIONS--
dba
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
$handler = 'cdb';
require_once(__DIR__ .'/skipif.inc');
?>
--FILE--
<?php
$handler = 'cdb';
$db_file = __DIR__.'/test.cdb';
$db =dba_open($db_file, "r", $handler);
try {
dba_fetch("1", $db, PHP_INT_MIN);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
dba_fetch("1", $db, PHP_INT_MAX);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
// negative skip needs to remain acceptable albeit corrected down the line
var_dump(dba_fetch("1", $db, -1000000));
?>
--EXPECTF--
dba_fetch(): Argument #3 ($skip) must be between -%d and %d
dba_fetch(): Argument #3 ($skip) must be between -%d and %d
Notice: dba_fetch(): Handler cdb accepts only skip values greater than or equal to zero, using skip=0 in %s on line %d
string(1) "1"