File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -984,6 +984,11 @@ PHP_FUNCTION(dba_fetch)
984
984
ZEND_PARSE_PARAMETERS_END ();
985
985
}
986
986
987
+ if (ZEND_LONG_EXCEEDS_INT (skip )) {
988
+ zend_argument_value_error (3 , "must be between %d and %d" , INT_MIN , INT_MAX );
989
+ RETURN_THROWS ();
990
+ }
991
+
987
992
DBA_FETCH_RESOURCE (info , id );
988
993
989
994
if (key_ht ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-19885 (dba_fetch() segfault on large skip values)
3
+ --SKIPIF--
4
+ <?php
5
+ if (PHP_INT_SIZE != 8 ) die ("skip this test is for 64bit platform only " );
6
+ require_once (__DIR__ .'/skipif.inc ' );
7
+ die ("info $ HND handler used " );
8
+ ?>
9
+ --FILE--
10
+ <?php
11
+ $ handler = 'cdb ' ;
12
+ $ db_file = __DIR__ .'/test.cdb ' ;
13
+ $ db =dba_open ($ db_file , "r " , $ handler );
14
+ try {
15
+ dba_fetch ("1 " , $ db , PHP_INT_MIN );
16
+ } catch (\ValueError $ e ) {
17
+ echo $ e ->getMessage (), PHP_EOL ;
18
+ }
19
+
20
+ try {
21
+ dba_fetch ("1 " , $ db , PHP_INT_MAX );
22
+ } catch (\ValueError $ e ) {
23
+ echo $ e ->getMessage (), PHP_EOL ;
24
+ }
25
+ // negative skip needs to remain acceptable albeit corrected down the line
26
+ var_dump (dba_fetch ("1 " , $ db , -1000000 ));
27
+ ?>
28
+ --EXPECTF--
29
+ dba_fetch(): Argument #3 ($skip) must be between %i and %d
30
+ dba_fetch(): Argument #3 ($skip) must be between %i and %d
31
+
32
+ Notice: dba_fetch(): Handler cdb accepts only skip values greater than or equal to zero, using skip=0 in %s on line %d
33
+ string(1) "1"
You can’t perform that action at this time.
0 commit comments