From: [EMAIL PROTECTED] Operating system: kubuntu linux PHP version: 5.2.0 PHP Bug Type: Streams related Bug description: stream_copy_to_stream() with filters truncates output
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) -- Edit bug report at http://bugs.php.net/?id=40188&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40188&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40188&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40188&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40188&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40188&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40188&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40188&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40188&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40188&r=support Expected behavior: http://bugs.php.net/fix.php?id=40188&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40188&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40188&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40188&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40188&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40188&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40188&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40188&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40188&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40188&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40188&r=mysqlcfg