mirror of
https://github.com/php/php-src.git
synced 2024-09-23 10:57:26 +00:00
MFH: Fixed bug #48307 (stream_copy_to_stream() copies 0 bytes when $source
is a socket)
This commit is contained in:
parent
06a10f3789
commit
a2600facdd
30
ext/standard/tests/streams/stream_copy_to_stream_socket.phpt
Normal file
30
ext/standard/tests/streams/stream_copy_to_stream_socket.phpt
Normal 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"
|
@ -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 (php_stream_stat(src, &ssbuf) == 0) {
|
||||||
if (ssbuf.sb.st_size == 0
|
if (ssbuf.sb.st_size == 0
|
||||||
#ifdef S_ISFIFO
|
#ifdef S_ISREG
|
||||||
&& !S_ISFIFO(ssbuf.sb.st_mode)
|
&& S_ISREG(ssbuf.sb.st_mode)
|
||||||
#endif
|
|
||||||
#ifdef S_ISCHR
|
|
||||||
&& !S_ISCHR(ssbuf.sb.st_mode)
|
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user