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 @@ -1062,6 +1062,11 @@ PHP_FUNCTION(dba_fetch)
10621062 ZEND_PARSE_PARAMETERS_END ();
10631063 }
10641064
1065+ if (ZEND_LONG_EXCEEDS_INT (skip )) {
1066+ zend_argument_value_error (3 , "must be between %d and %d" , INT_MIN , INT_MAX );
1067+ RETURN_THROWS ();
1068+ }
1069+
10651070 info = Z_DBA_INFO_P (id );
10661071 CHECK_DBA_CONNECTION (info );
10671072
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