ID:               42237
 User updated by:  andrew dot minerd at sellingsource dot com
 Reported By:      andrew dot minerd at sellingsource dot com
 Status:           Open
 Bug Type:         Streams related
 Operating System: Gentoo
 PHP Version:      5.2.4RC1
 New Comment:

Erm, I changed haveread to written for clarity... obviously you'd have
to define the variable, etc -- that was missing from my patch. :-p


Previous Comments:
------------------------------------------------------------------------

[2007-08-07 20:26:00] andrew dot minerd at sellingsource dot com

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;
                }
        }

------------------------------------------------------------------------

[2007-08-07 20:24:04] 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)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=42237&edit=1

Reply via email to