|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47997 stream_copy_to_stream returns 1 on empty streams
Submitted: 2009-04-16 23:52 UTC Modified: 2009-04-19 13:56 UTC
From: robots at shad dot pp dot ru Assigned:
Status: Closed Package: Streams related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID:
 [2009-04-16 23:52 UTC] robots at shad dot pp dot ru
Function returns 1 even if used to copy empty stream.

Reproduce code:

// Creating empty file
$src = fopen('srcfile.tmp', 'w+');

$src = fopen('srcfile.tmp', 'r');
$dst = fopen('dstfile.tmp', 'w+');

echo stream_copy_to_stream($src, $dst);



Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-17 11:08 UTC]
From streams.c:

"in the event that the source file is 0 bytes, return 1 to indicate success because opening the file to write had already created a copy"

Looks like yet another design flaw in the streams API. 
 [2009-04-19 13:56 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.

 [2012-02-25 10:58 UTC]
Automatic comment from SVN on behalf of odoucet
Log: fix test file for bug #47997 : fopen(data://) requires allow_url_fopen=1
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 02:01:31 2015 UTC