ID:               35849
 Updated by:       [EMAIL PROTECTED]
 Reported By:      sqchen at citiz dot net
-Status:           Open
+Status:           Assigned
-Bug Type:         Unknown/Other Function
+Bug Type:         Filesystem function related
-Operating System: redhat 7.3
+Operating System: *
-PHP Version:      5.1.1
+PHP Version:      5CVS-2005-12-30 (cvs)
-Assigned To:      
+Assigned To:      wez
 New Comment:

Assigned to the streams maintainer.


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

[2005-12-30 13:32:52] [EMAIL PROTECTED]

I can see two bugs in this report:
 * mmap()'ed fds aren't seeked() to update the position
 * the length is a size_t, where it should be a ssize_t, because
PHP_STREAM_COPY_ALL is defined to -1

my patch: http://mega.ist.utl.pt/~ncpl/php_stream_mmap.txt
it makes all negative values to read all the file (to be consistent
with non-mmap'ed fds).

I can also see some long/size_t/ssize_t mixes, which can be problematic
in some platforms.

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

[2005-12-30 08:25:20] sqchen at citiz dot net

SORRY, I have make a mistake on the code above, Below is the right
code


Description:
------------
stream_copy_to_stream() do strange behavior when the maxlength
parameter
is negative, see the following codes:

Reproduce code:
---------------
<?php
$src   = fopen("1.txt", "r");  //"hell, world" in "1.txt"
$dest1 = fopen("des1.txt", "w");
$dest2 = fopen("des2.txt", "w");

/*----seg1------*/
stream_copy_to_stream($src, $des1, -2);
readfile("des1.txt");   //hello, world
stream_copy_to_stream($src, $des2);
readfile("des2.txt");   //nothing? why?

/* please compare it with seg2*/

/*----seg2-------*/
stream_copy_to_stream($src, $des1, 2);
readfile("des1.txt");   //he
stream_copy_to_stream($src, $des2);
readfile("des2.txt");   //hello, world
?>

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

[2005-12-30 07:43:17] sqchen at citiz dot net

Description:
------------
stream_copy_to_stream() do strange behavior when the maxlength
parameter is negative, see the following codes:

Reproduce code:
---------------
<?php
$src   = fopen("1.txt", "r");  //"hell, world" in "1.txt"
$dest1 = fopen("des1.txt", "w");
$dest2 = fopen("des2.txt", "w");

/*----seg1------*/
stream_copy_to_stream($src, $des1, -2);
readfile("des1.txt");   //hello, world
stream_copy_to_stream($src, $des1);
readfile("des2.txt");   //nothing? why?


/* please compare it with seg2*/

/*----seg2-------*/
stream_copy_to_stream($src, $des1, 2);
readfile("des1.txt");   //he
stream_copy_to_stream($src, $des1);
readfile("des2.txt");   //hello, world
?>




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


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

Reply via email to