|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38086 stream_copy_to_stream() returns bad value
Submitted: 2006-07-13 02:50 UTC Modified: 2006-07-13 12:00 UTC
From: webrika at mail dot ru Assigned:
Status: Closed Package: Streams related
PHP Version: 5.1.4 OS: FreeBSD 6.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: webrika at mail dot ru
New email:
PHP Version: OS:


 [2006-07-13 02:50 UTC] webrika at mail dot ru
stream_copy_to_stream() returns 0 when maxlength is bigger then the actual length. But copying is ok.

Reproduce code:
$src = fopen('', 'r');
$dest = fopen('ok.txt', 'w');
echo stream_copy_to_stream($src, $dest) . " bytes copied\n";
fclose($src); fclose($dest);

$src = fopen('', 'r');
$dest = fopen('BUG.txt', 'w');
echo stream_copy_to_stream($src, $dest, 100000) . " bytes copied\n"; // returns zero
fclose($src); fclose($dest);

echo filesize('ok.txt')."\n";
echo filesize('BUG.txt')."\n";

Expected result:
39821 bytes copied
39821 bytes copied

Actual result:
39821 bytes copied
0 bytes copied


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-13 12:00 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Feb 07 14:03:41 2023 UTC