From:             phpor dot net at gmail dot com
Operating system: all
PHP version:      5.4.8
Package:          HTTP related
Bug Type:         Bug
Bug description:php_stream_url_wrap_http_ex() function

Description:
------------
in function php_stream_url_wrap_http_ex has some codes like :

-------------------------------------- ext/standard/http_fopen_wrapper.c
php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char
*path, 
char *mode, int options, char **opened_path, php_stream_context *context,
int 
redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
{
...
                        if (*e != '\n') {
                                do { /* partial header */
                                        php_stream_get_line(stream, 
http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length);
                                        e = http_header_line + 
http_header_line_length - 1;
                                } while (*e != '\n');
                                continue;
                        }
...
}
-----------------------------------------------------------------

in this code block , it not check the result of php_stream_get_line(...) ;
if 
the stream lost connect at this time ,and the http header line not end
,then it 
will be cycle forever.

Test script:
---------------
------------------- server.php
<?php
$str = "HTTP/1.1 200 OK
Date: Sat, 07 Jul 2012 07:46:29 GMT";
fgets(STDIN);
echo $str;
exit;
?>
------------------- end

------------------- client.php
<?php
echo file_get_contents("http://localhost:9090/";);
exit;
?>
------------------- end

start server.php :
#mkfifo /tmp/fifo
#nc -l localhost -p 9090 </tmp/fifo | php server.php >/tmp/fifo

start client.php :
#php client.php


now , the client.php will cycle forever


Expected result:
----------------
expect return fail

Actual result:
--------------
the client.php will cycle forever

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63338&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63338&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63338&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63338&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63338&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63338&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63338&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63338&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63338&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63338&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63338&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63338&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63338&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63338&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63338&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63338&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63338&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63338&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63338&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63338&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63338&r=mysqlcfg

Reply via email to