|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-04 12:49 UTC] moriyoshi@php.net
$ cat Zend/zend.c | php script2.php
produces bogus output, whilst
$ php script1.php
and
$ php script3.php
work correctly.
script1.php:
<?php
$fin = fopen("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);
?>
script2.php:
<?php
$fin = fopen("php://stdin", "r");
$fout = fopen("/tmp/output", "w");
stream_filter_append($fout, "string.rot13");
stream_copy_to_stream($fin, $fout);
fclose($fin);
fclose($fout);
?>
script3.php:
<?php
$fin = fopen("php://stdin", "r");
$fout = fopen("/tmp/output", "w");
stream_filter_append($fin, "string.rot13");
stream_copy_to_stream($fin, $fout);
fclose($fin);
fclose($fout);
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
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.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 ;-)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 {