Bug #74090 [NEW]: stream_get_contents maxlength>-1 returns empty string on windows
| From: | me at micksam7 dot com | Date: | Mon, 13 Feb 2017 05:05:09 +0000 |
| Subject: | Bug #74090 [NEW]: stream_get_contents maxlength>-1 returns empty string on windows | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207364@lists.php.net to get a copy of this message | ||
From: me at micksam7 dot com
Operating system: Windows 10 v1607
PHP version: 7.1.1
Package: Streams related
Bug Type: Bug
Bug description:stream_get_contents maxlength>-1 returns empty string on windows
Description:
------------
stream_get_contents() with any maxlength greater than -1 returns an
empty string,
This only appears to occur with UDP streams opened via
stream_socket_client(), specifically on Windows 10.
This problem doesn't occur on Linux and may function fine on older
versions of Windows.
The problem appears to reside somewhere in the php_stream_eof call
within _php_stream_copy_to_mem - php_stream_eof seems to always return
true on UDP streams on Windows 10 systems. More digging required.
Test script:
---------------
//Submit DNS Request
$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);
var_dump(stream_get_contents($fd,65565)); //Does not work
var_dump(stream_get_contents($fd)); //No maxlength, works fine
stream_socket_shutdown($fd,STREAM_SHUT_RDWR);
Expected result:
----------------
Returns a valid DNS response roughly 45 bytes long, then an empty
string.
string(45) "<>"
string(0) ""
Actual result:
--------------
Returns an empty string, then a valid DNS response.
string(0) ""
string(45) "<>"
--
Edit bug report at https://bugs.php.net/bug.php?id=74090&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74090&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74090&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74090&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74090&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74090&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74090&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74090&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74090&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74090&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74090&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74090&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74090&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74090&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74090&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74090&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74090&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74090&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74090&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74090&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74090&r=mysqlcfg