php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63338 php_stream_url_wrap_http_ex() function
Submitted: 2012-10-23 08:50 UTC Modified: 2013-10-02 09:21 UTC
From: phpor dot net at gmail dot com Assigned: mike (profile)
Status: Closed Package: HTTP related
PHP Version: 5.4.8 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpor dot net at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-23 08:50 UTC] phpor dot net at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 09:21 UTC] mike@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 [2013-10-02 09:21 UTC] mike@php.net
Fixed in recent versions.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 23:01:29 2024 UTC