File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1070,6 +1070,11 @@ PHP_FUNCTION(dba_fetch)
1070
1070
ZEND_PARSE_PARAMETERS_END ();
1071
1071
}
1072
1072
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
+
1073
1078
info = Z_DBA_INFO_P (id );
1074
1079
CHECK_DBA_CONNECTION (info );
1075
1080
Original file line number Diff line number Diff line change
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"
You can’t perform that action at this time.
0 commit comments