Skip to content

Commit 439cea4

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
2 parents 44cbe73 + c5fe6c2 commit 439cea4

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ PHPAPI HashTable *php_fgetcsv(php_stream *stream, char delimiter, char enclosure
19701970
while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
19711971
tmp++;
19721972
}
1973-
if (*tmp == enclosure) {
1973+
if (*tmp == enclosure && tmp < limit) {
19741974
bptr = tmp;
19751975
}
19761976
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
oss-fuzz #57392: Buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
3+
--FILE--
4+
<?php
5+
var_dump(str_getcsv(
6+
"aaaaaaaaaaaa\0 ",
7+
"\0",
8+
"\0",
9+
));
10+
?>
11+
--EXPECT--
12+
array(2) {
13+
[0]=>
14+
string(12) "aaaaaaaaaaaa"
15+
[1]=>
16+
string(2) " "
17+
}

0 commit comments

Comments
 (0)