Bug #60826 [Com]: raw POST data missing with chunked encoding, FastCGI

From: Date: Mon, 23 Apr 2012 10:59:25 +0000
Subject: Bug #60826 [Com]: raw POST data missing with chunked encoding, FastCGI
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-169892@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60826&edit=1

 ID:                 60826
 Comment by:         florian dot fernandez at navaho dot fr
 Reported by:        clarkwise at gmail dot com
 Summary:            raw POST data missing with chunked encoding, FastCGI
 Status:             Assigned
 Type:               Bug
 Package:            CGI/CLI related
 Operating System:   Windows XP
 PHP Version:        5.3.9
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

Maybe I did something wrong but the patch doesn't seem to work with PHP 5.4.0 on Linux.


Previous Comments:
------------------------------------------------------------------------
[2012-04-23 08:08:19] florian dot fernandez at navaho dot fr

Sorry, I didn't see it before. I'll give it a try with 5.4.0

------------------------------------------------------------------------
[2012-04-23 08:00:32] andres at fenestrae dot com

florian dot fernandez at navaho dot fr 

I have been able to try my solution in combination with 5.2.17.

See the patches in this topic for the exact code-changes I made.

------------------------------------------------------------------------
[2012-04-23 07:52:12] florian dot fernandez at navaho dot fr

@ andres at fenestrae dot com

Have you been able to try what you suggested in your last post ?

------------------------------------------------------------------------
[2012-04-11 13:24:05] andres at fenestrae dot com

The problem lies in php-cgi.exe.
I have been able to reproduce the problem on IIS 7.5.
In Fast-cgi the data is delivered using method similar to chunking.

In case of "Transfer-Encoding: chunked" IIS supplies Content-length:-1 in the request
data, which is casted to uint in sapi_cgi_read_post. Causing the routine to read data until it has
read the full 4G (2^32-1).
Also, both the methods sapi_cgi_read_post(cgi_main.c) and fcgi_read(fastcgi.c) try to read the
complete buffer time after time, causing the end-marker (0-sized chunk) only to be seen when it
would be at buffer-boundary. However the sapi_cgi_read_post funtion is called several times after
the actual content has been read causing the fcgi_read method to block.
I expect similar cause to apply for apache.

Solution appears
1) do not loop in fcgi_read; this way when reading the final marker, it is returned to the calling
code.
2) Set SG(request_info).content_length to SG(read_post_bytes) + read_bytes when tmp_read_bytes ==0
&& SG(request_info).content_length == -1

------------------------------------------------------------------------
[2012-04-03 13:02:34] florian dot fernandez at navaho dot fr

@ab at php dot net

Unfortunately, I won't be able to test with nginx because the system administrators won't
let me install it (Only Apache is allowed). Sorry for the inconvenience. I'll try to open a new
bug on Apache bug list or mod_fcigd bug list if I find it : maybe they'll look into it.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=60826


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60826&edit=1


Thread (30 messages)

« previous php.bugs (#169892) next »