|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-22 07:17 UTC] tony2001@php.net
[2008-07-13 16:07 UTC] jani@php.net
[2008-07-21 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 23:00:02 2025 UTC |
Description: ------------ This was detected in the phar extension, but can be reproduced with regular php code. Because _php_stream_read in main/streams/streams.c automatically truncates output from a streams filter to the maximum requested amount, this does not allow the possibility of specifying pre-filter amount of bytes to read. "new b" is 5 bytes, but zlib deflates it to a 7-byte length. Because writepos is > toread, it is cut to 5 bytes. A new flag is needed to specify that we want to read a maximum bytes, not write a maximum bytes. Although I put "int(7)" in the expected output, I don't expect this output unless a flag is passed that specifically asks to do this. Reproduce code: --------------- <?php file_put_contents('test1.txt', 'new b/next thing'); $a = fopen('test1.txt', 'rb'); $newa = fopen('test2.txt', 'wb'); stream_filter_append($a, 'zlib.deflate'); $b = stream_copy_to_stream($a, $newa, 5); var_dump($b, ftell($newa)); Expected result: ---------------- int(5) int(7) Actual result: -------------- int(5) int(5)