Skip to content

Commit ea82251

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 9382260 + 933e087 commit ea82251

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

ext/dba/dba.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,11 @@ PHP_FUNCTION(dba_fetch)
10701070
ZEND_PARSE_PARAMETERS_END();
10711071
}
10721072

1073+
if (ZEND_LONG_EXCEEDS_INT(skip)) {
1074+
zend_argument_value_error(3, "must be between %d and %d", INT_MIN, INT_MAX);
1075+
RETURN_THROWS();
1076+
}
1077+
10731078
info = Z_DBA_INFO_P(id);
10741079
CHECK_DBA_CONNECTION(info);
10751080

ext/dba/tests/gh19885.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
GH-19885 (dba_fetch() segfault on large skip values)
3+
--EXTENSIONS--
4+
dba
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
8+
$handler = 'cdb';
9+
require_once(__DIR__ .'/skipif.inc');
10+
?>
11+
--FILE--
12+
<?php
13+
$handler = 'cdb';
14+
$db_file = __DIR__.'/test.cdb';
15+
$db =dba_open($db_file, "r", $handler);
16+
try {
17+
dba_fetch("1", $db, PHP_INT_MIN);
18+
} catch (\ValueError $e) {
19+
echo $e->getMessage(), PHP_EOL;
20+
}
21+
22+
try {
23+
dba_fetch("1", $db, PHP_INT_MAX);
24+
} catch (\ValueError $e) {
25+
echo $e->getMessage(), PHP_EOL;
26+
}
27+
// negative skip needs to remain acceptable albeit corrected down the line
28+
var_dump(dba_fetch("1", $db, -1000000));
29+
?>
30+
--EXPECTF--
31+
dba_fetch(): Argument #3 ($skip) must be between -%d and %d
32+
dba_fetch(): Argument #3 ($skip) must be between -%d and %d
33+
34+
Notice: dba_fetch(): Handler cdb accepts only skip values greater than or equal to zero, using skip=0 in %s on line %d
35+
string(1) "1"

0 commit comments

Comments
 (0)