php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40188 stream_copy_to_stream() with filters truncates output
Submitted: 2007-01-21 22:07 UTC Modified: 2008-07-21 01:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cellog@php.net Assigned: pollita (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.2.0 OS: kubuntu linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cellog@php.net
New email:
PHP Version: OS:

 

 [2007-01-21 22:07 UTC] cellog@php.net
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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-22 07:17 UTC] tony2001@php.net
Sara, could you look into this?
 [2008-07-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC