|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-07 20:24 UTC] andrew dot minerd at sellingsource dot com
Description:
------------
When copying from a memmapped stream, stream_copy_to_stream returns the length of the memory-mapped segment, regardless of how much data was actually written to the recipient stream.
Reproduce code:
---------------
<?php
class DummyWriteStream
{
function stream_open($path, $mode, $options, &$opened_path) { return TRUE; }
function stream_write($data) { return 0; }
}
stream_wrapper_register('test2', 'DummyWriteStream');
$fp1 = fopen('/etc/hosts', 'r');
$fp2 = fopen('test2://test', 'w');
var_dump(stream_copy_to_stream($fp1, $fp2, 8192));
?>
Expected result:
----------------
int(0)
Actual result:
--------------
int(1228)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Patch: --- streams.c 2007-01-15 09:07:07.000000000 -0800 +++ streams2.c 2007-08-07 13:23:14.000000000 -0700 @@ -1309,11 +1309,11 @@ p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped); if (p) { - haveread = php_stream_write(dest, p, mapped); + written = php_stream_write(dest, p, mapped); php_stream_mmap_unmap(src); - return mapped; + return written; } }