File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ PHP NEWS
1919 . Fixed GH-17159: "P" format for ::createFromFormat swallows string literals.
2020 (nielsdos)
2121
22+ - DBA:
23+ . Fixed GH-19885 (dba_fetch() overflow on skip argument). (David Carlier)
24+
2225- Curl:
2326 . Fix cloning of CURLOPT_POSTFIELDS when using the clone operator instead
2427 of the curl_copy_handle() function to clone a CurlHandle. (timwolla)
Original file line number Diff line number Diff line change @@ -984,6 +984,11 @@ PHP_FUNCTION(dba_fetch)
984984 ZEND_PARSE_PARAMETERS_END ();
985985 }
986986
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+
987992 DBA_FETCH_RESOURCE (info , id );
988993
989994 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+ --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