#22538 [Opn->Ana]: stream filter produces bogus output
| From: | moriyoshi@php.net | Date: | Fri, 28 Mar 2003 16:59:38 +0000 |
| Subject: | #22538 [Opn->Ana]: stream filter produces bogus output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-36655@lists.php.net to get a copy of this message | ||
ID: 22538
Updated by: moriyoshi@php.net
Reported By: moriyoshi@php.net
-Status: Open
+Status: Analyzed
Bug Type: Filesystem function related
Operating System: RedHat Linux 8.0 (glibc-2.3.0)
PHP Version: 5CVS-2003-03-04 (dev)
Assigned To: iliaa
New Comment:
I made a patch for this issue. But not sure if this is the right fix..
Index: main/streams/streams.c
===================================================================
RCS file: /repository/php4/main/streams/streams.c,v
retrieving revision 1.14
diff -u -r1.14 streams.c
--- main/streams/streams.c 20 Mar 2003 01:23:04 -0000 1.14
+++ main/streams/streams.c 28 Mar 2003 16:50:31 -0000
@@ -829,7 +829,7 @@
/* Only screw with the buffer if we can seek, otherwise we lose
data
* buffered from fifos and sockets */
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK)
== 0 && !php_stream_is_filtered(stream)) {
+ if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK)
== 0) {
stream->position += justwrote;
}
} else {
Previous Comments:
------------------------------------------------------------------------
[2003-03-17 14:58:15] moriyoshi@php.net
And, hmm, here's another script to replicate with.
By this script, It turned out that the issue isn't
stream_copy_to_stream specific.
<?php
function my_stream_copy_to_stream($fin, $fout) {
while (!feof($fin)) {
fwrite($fout, fread($fin, 4096));
}
}
$fin = fopen("Zend/zend.c", "r");
$fout = fopen("/tmp/output", "w");
stream_filter_append($fout, "string.rot13");
my_stream_copy_to_stream($fin, $fout);
fclose($fin);
fclose($fout);
?>
I don't have enough time to fix this right now, so I thank you for
taking your time to look at this one ;-)
------------------------------------------------------------------------
[2003-03-17 14:34:13] moriyoshi@php.net
Oops, I forgot to try this one...
script 4:
<?php
$fin = popen("cat Zend/zend.c", "r");
$fout = fopen("/tmp/output", "w");
stream_filter_append($fout, "string.rot13");
stream_copy_to_stream($fin, $fout);
fclose($fin);
fclose($fout);
?>
This results in the same output.
------------------------------------------------------------------------
[2003-03-17 14:30:08] moriyoshi@php.net
The bug still persists.
$ php script2.php < Zend/zend.c
is ok, but it doesn't work with piped stream. Please try the
following:
$ cat script2.php | php script2.php
------------------------------------------------------------------------
[2003-03-17 12:33:46] iliaa@php.net
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2003-03-17 08:26:28] moriyoshi@php.net
Is this a sort of mmap() problem? I have no idea about this problem at
all..
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/22538
--
Edit this bug report at http://bugs.php.net/?id=22538&edit=1