mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-12151: str_getcsv ending with escape zero segfualt
Closes GH-12152
This commit is contained in:
4
NEWS
4
NEWS
@@ -32,6 +32,10 @@ PHP NEWS
|
||||
. Fixed bug GH-11972 (RecursiveCallbackFilterIterator regression in 8.1.18).
|
||||
(nielsdos)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug GH-12151 (str_getcsv ending with escape zero segfualt).
|
||||
(Jakub Zelenka)
|
||||
|
||||
31 Aug 2023, PHP 8.3.0RC1
|
||||
|
||||
- Core:
|
||||
|
||||
@@ -2023,6 +2023,9 @@ PHPAPI HashTable *php_fgetcsv(php_stream *stream, char delimiter, char enclosure
|
||||
if (bptr > limit) {
|
||||
/* if the line ends with enclosure, we need to go back by
|
||||
* one character so the \0 character is not copied. */
|
||||
if (hunk_begin == bptr) {
|
||||
--hunk_begin;
|
||||
}
|
||||
--bptr;
|
||||
}
|
||||
goto quit_loop_2;
|
||||
@@ -2038,6 +2041,9 @@ PHPAPI HashTable *php_fgetcsv(php_stream *stream, char delimiter, char enclosure
|
||||
if (bptr > limit) {
|
||||
/* if the line ends with enclosure, we need to go back by
|
||||
* one character so the \0 character is not copied. */
|
||||
if (hunk_begin == bptr) {
|
||||
--hunk_begin;
|
||||
}
|
||||
--bptr;
|
||||
}
|
||||
goto quit_loop_2;
|
||||
|
||||
14
ext/standard/tests/strings/gh12151.phpt
Normal file
14
ext/standard/tests/strings/gh12151.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
GH-12151 (str_getcsv ending with escape zero segfualt)
|
||||
--FILE--
|
||||
<?php
|
||||
var_export(str_getcsv("y","","y","\000"));
|
||||
var_export(str_getcsv("\0yy","y","y","\0"));
|
||||
?>
|
||||
--EXPECT--
|
||||
array (
|
||||
0 => '' . "\0" . '',
|
||||
)array (
|
||||
0 => '' . "\0" . '',
|
||||
1 => '' . "\0" . '',
|
||||
)
|
||||
Reference in New Issue
Block a user