MFH: Fixed bug #48307 (stream_copy_to_stream() copies 0 bytes when $source

is a socket)
This commit is contained in:
Arnaud Le Blanc 2009-05-16 20:23:06 +00:00
parent 06a10f3789
commit a2600facdd
2 changed files with 32 additions and 5 deletions

View File

@ -0,0 +1,30 @@
--TEST--
stream_copy_to_stream() with socket as $source
--SKIPIF--
<?php
$sockets = @stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
if (!$sockets) die("skip stream_socket_pair");
?>
--FILE--
<?php
$sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
$tmp = tmpfile();
fwrite($sockets[0], b"a");
stream_socket_shutdown($sockets[0], STREAM_SHUT_WR);
stream_copy_to_stream($sockets[1], $tmp);
fseek($tmp, 0, SEEK_SET);
var_dump(stream_get_contents($tmp));
stream_copy_to_stream($sockets[1], $tmp);
fseek($tmp, 0, SEEK_SET);
var_dump(stream_get_contents($tmp));
?>
--EXPECT--
string(1) "a"
string(1) "a"

View File

@ -1322,11 +1322,8 @@ PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, s
if (php_stream_stat(src, &ssbuf) == 0) {
if (ssbuf.sb.st_size == 0
#ifdef S_ISFIFO
&& !S_ISFIFO(ssbuf.sb.st_mode)
#endif
#ifdef S_ISCHR
&& !S_ISCHR(ssbuf.sb.st_mode)
#ifdef S_ISREG
&& S_ISREG(ssbuf.sb.st_mode)
#endif
) {
*len = 0;