|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
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
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 */
http_header_line, HTTP_HEADER_BLOCK_SIZE, &http_header_line_length);
					e = http_header_line + 
http_header_line_length - 1;
				} while (*e != '\n');

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
$str = "HTTP/1.1 200 OK
Date: Sat, 07 Jul 2012 07:46:29 GMT";
echo $str;
------------------- end

------------------- client.php
echo file_get_contents("http://localhost:9090/");
------------------- 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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 09:21 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 [2013-10-02 09:21 UTC]
Fixed in recent versions.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jun 13 12:01:23 2021 UTC