#50196 [Opn->Csd]: stream_copy_to_stream() produces warning when source is not file
| From: | stas@php.net | Date: | Sat, 19 Dec 2009 01:13:55 +0000 |
| Subject: | #50196 [Opn->Csd]: stream_copy_to_stream() produces warning when source is not file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145924@lists.php.net to get a copy of this message | ||
ID: 50196
Updated by: stas@php.net
Reported By: stas at zend dot com
-Status: Open
+Status: Closed
Bug Type: Streams related
Operating System: win32 only
PHP Version: 5.2SVN-2009-11-16 (SVN)
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-12-19 01:13:33] svn@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&revision=292309
Log: fix bug #50196
------------------------------------------------------------------------
[2009-11-17 17:42:23] stas@php.net
Is it really that hard to find a script that opens http socket in the
manual? OK, here it goes:
<?php
$socket = fsockopen("localhost", 80, $errno, $errstr, 30);
if (!$socket) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: localhost\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($socket, $out);
}
$fp = fopen("data", "w");
stream_copy_to_stream($socket, $fp);
------------------------------------------------------------------------
[2009-11-16 22:08:27] stas at zend dot com
Description:
------------
If I use stream_copy_to_stream with source stream being not file (say,
HTTP socket) then I get this warning:
Warning: Invalid CRT parameters detected
This is because in _php_stream_copy_to_stream_ex() php_stream_stat() is
applied to source stream, which goes to php_sockop_stat which calls
fstat, which produces "invalid parameter" pseudo-exception.
Reproduce code:
---------------
$socket = open_http_socket();
$fp = fopen("data", "w");
stream_copy_to_stream($socket, $fp);
Actual result:
--------------
Warning: Invalid CRT parameters detected
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50196&edit=1