Skip to content

Commit c5fe6c2

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix buffer-overflow in php_fgetcsv() with \0 delimiter and enclosure
2 parents 834e295 + 57029ce commit c5fe6c2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ PHP NEWS
7171
. Fixed bug GH-10885 (stream_socket_server context leaks). (ilutov)
7272
. Fixed bug GH-10052 (Browscap crashes PHP 8.1.12 on request shutdown
7373
(apache2)). (nielsdos)
74+
. Fixed oss-fuzz #57392 (Buffer-overflow in php_fgetcsv() with \0 delimiter
75+
and enclosure). (ilutov)
7476

7577
16 Mar 2023, PHP 8.2.4
7678

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)