Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-11242: Use dynamic buffer for large length in stream mem copy
- Loading branch information
Showing
3 changed files
with
50 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ext/standard/tests/file/file_get_contents_with_large_length.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
Test file_get_contents() function with large length parameter | ||
--INI-- | ||
memory_limit=128M | ||
--FILE-- | ||
<?php | ||
|
||
$file_path = __DIR__ . '/file_get_contents_with_large_length_content.txt'; | ||
$file_content = str_repeat('a', 50000); | ||
file_put_contents($file_path, $file_content); | ||
|
||
// test lenght limiting | ||
$result = file_get_contents($file_path, length: 500000000); | ||
var_dump($result === $file_content); | ||
|
||
// test lenght limiting | ||
$result = file_get_contents($file_path, length: 40000); | ||
var_dump($result === str_repeat('a', 40000)); | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
unlink(__DIR__ . '/file_get_contents_with_large_length_content.txt'); | ||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters