-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #81092: fflush before stream_filter_remove corrupts stream
When doing a non finishing flush, BZ2_bzCompress() returns BZ_FLUSH_OK (not BZ_FINISH_OK) what requires us to do further flushes right away. We also refactor the while-loop as do-loop. Closes GH-7113.
- Loading branch information
Showing
3 changed files
with
28 additions
and
3 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
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
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,22 @@ | ||
--TEST-- | ||
Bug #81092 (fflush before stream_filter_remove corrupts stream) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('bz2')) die('skip bz2 extension not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
$stream = fopen(__DIR__ . "/81092.bz2", 'wb+'); | ||
$filter = stream_filter_append($stream, 'bzip2.compress', STREAM_FILTER_WRITE, ['blocks' => 9, 'work' => 0]); | ||
fwrite($stream, random_bytes(8192)); | ||
fflush($stream); | ||
stream_filter_remove($filter); | ||
|
||
var_dump(strlen(bzdecompress(file_get_contents(__DIR__ . "/81092.bz2")))); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
@unlink(__DIR__ . "/81092.bz2"); | ||
?> | ||
--EXPECT-- | ||
int(8192) |