diff --git a/ext/standard/file.c b/ext/standard/file.c index 4c31ee0eae66..548bcc7a37ca 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2088,7 +2088,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, int while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) { tmp++; } - if (*tmp == enclosure) { + if (*tmp == enclosure && tmp < limit) { bptr = tmp; } } diff --git a/ext/standard/tests/oss_fuzz_57392.phpt b/ext/standard/tests/oss_fuzz_57392.phpt new file mode 100644 index 000000000000..a7f7a466c0e0 --- /dev/null +++ b/ext/standard/tests/oss_fuzz_57392.phpt @@ -0,0 +1,17 @@ +--TEST-- +oss-fuzz #57392: str_getcsv() with null byte as delimiter and enclosure +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + string(12) "aaaaaaaaaaaa" + [1]=> + string(2) " " +}