mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed bug #74090 stream_get_contents maxlength>-1 returns empty string
This commit is contained in:
parent
3917350531
commit
89a5bd6750
3 changed files with 27 additions and 1 deletions
22
ext/standard/tests/streams/bug74090.phpt
Normal file
22
ext/standard/tests/streams/bug74090.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #74090 stream_get_contents maxlength>-1 returns empty string on windows
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (getenv("SKIP_ONLINE_TESTS")) { die('skip: online test'); }
|
||||||
|
if (getenv("SKIP_SLOW_TESTS")) { die('skip: slow test'); }
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$data = base64_decode("1oIBAAABAAAAAAAAB2V4YW1wbGUDb3JnAAABAAE=");
|
||||||
|
$fd = stream_socket_client("udp://8.8.8.8:53", $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
|
||||||
|
stream_set_blocking($fd, 0);
|
||||||
|
stream_socket_sendto($fd,$data);
|
||||||
|
sleep(1);
|
||||||
|
$ret = stream_get_contents($fd,65565);
|
||||||
|
var_dump(strlen($ret) > 0);
|
||||||
|
stream_socket_shutdown($fd,STREAM_SHUT_RDWR);
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECTF--
|
||||||
|
bool(true)
|
||||||
|
==DONE==
|
|
@ -53,6 +53,10 @@
|
||||||
# undef EWOULDBLOCK
|
# undef EWOULDBLOCK
|
||||||
# endif
|
# endif
|
||||||
# define EWOULDBLOCK WSAEWOULDBLOCK
|
# define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
|
# ifdef EMSGSIZE
|
||||||
|
# undef EMSGSIZE
|
||||||
|
# endif
|
||||||
|
# define EMSGSIZE WSAEMSGSIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
|
/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
|
||||||
|
|
|
@ -336,7 +336,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
|
||||||
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK);
|
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK);
|
||||||
err = php_socket_errno();
|
err = php_socket_errno();
|
||||||
if (0 == ret || /* the counterpart did properly shutdown*/
|
if (0 == ret || /* the counterpart did properly shutdown*/
|
||||||
(0 > ret && err != EWOULDBLOCK && err != EAGAIN)) { /* there was an unrecoverable error */
|
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
|
||||||
alive = 0;
|
alive = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue