File tree 4 files changed +29
-6
lines changed
4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ PHP NEWS
89
89
- Standard:
90
90
. Fix passing non-finite timeout values in stream functions. (nielsdos)
91
91
. Fixed GH-14780 p(f)sockopen timeout overflow. (David Carlier)
92
+ . Fixed GH-15653 overflow on fgetcsv length parameter. (David Carlier)
92
93
93
94
- Streams:
94
95
. Fixed bug GH-15028 (Memory leak in ext/phar/stream.c). (nielsdos)
Original file line number Diff line number Diff line change @@ -1895,8 +1895,8 @@ PHP_FUNCTION(fgetcsv)
1895
1895
1896
1896
if (len_is_null || len == 0 ) {
1897
1897
len = -1 ;
1898
- } else if (len < 0 ) {
1899
- zend_argument_value_error (2 , "must be a greater than or equal to 0" );
1898
+ } else if (len < 0 || len > ( ZEND_LONG_MAX - 1 ) ) {
1899
+ zend_argument_value_error (2 , "must be between 0 and " ZEND_LONG_FMT , ( ZEND_LONG_MAX - 1 ) );
1900
1900
RETURN_THROWS ();
1901
1901
}
1902
1902
Original file line number Diff line number Diff line change @@ -48,11 +48,11 @@ try {
48
48
echo $ e ->getMessage () . \PHP_EOL ;
49
49
}
50
50
?>
51
- --EXPECT --
51
+ --EXPECTF --
52
52
fgetcsv() with negative length
53
- fgetcsv(): Argument #2 ($length) must be a greater than or equal to 0
54
- fgetcsv(): Argument #2 ($length) must be a greater than or equal to 0
55
- fgetcsv(): Argument #2 ($length) must be a greater than or equal to 0
53
+ fgetcsv(): Argument #2 ($length) must be between 0 and %d
54
+ fgetcsv(): Argument #2 ($length) must be between 0 and %d
55
+ fgetcsv(): Argument #2 ($length) must be between 0 and %d
56
56
fgetcsv() with delimiter as empty string
57
57
fgetcsv(): Argument #3 ($separator) must be a single character
58
58
fgetcsv() with enclosure as empty string
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-15653 (fgetcsv overflow on length argument)
3
+ --FILE--
4
+ <?php
5
+ $ filename = __DIR__ . "/gh15653.tmp " ;
6
+ touch ($ filename );
7
+ $ fp = fopen ($ filename , "r " );
8
+
9
+ try {
10
+ fgetcsv ($ fp , PHP_INT_MAX );
11
+ } catch (\ValueError $ e ) {
12
+ echo $ e ->getMessage () . PHP_EOL ;
13
+ }
14
+
15
+ fgetcsv ($ fp , PHP_INT_MAX -1 );
16
+ --CLEAN --
17
+ <?php
18
+ @unlink (__DIR__ . "/gh15653.tmp " );
19
+ ?>
20
+ --EXPECTF--
21
+ fgetcsv(): Argument #2 ($length) must be between 0 and %d
22
+ %A
You can’t perform that action at this time.
0 commit comments