From:             andreas dot streichardt at globalpark dot com
Operating system: Linux
PHP version:      5.3.0
PHP Bug Type:     Filter related
Bug description:  dechunked filter broken when serving more than 8192 bytes in 
a chunk

Description:
------------
The dechunked filter is broken when the webserver is serving more than
8192 bytes in a chunk. When it reenters the function to read from the
buffer the function thinks a new chunk is coming along although the chunk
is not yet read up to the end and thinks the chunk is broken.

I made a quick test and Apache seems to always serve 8192 bytes in a
chunk. However lighttpd for example serves much more. So reading HTTP/1.1
streams with Transfer-Encoding: chunked is always broken on larger
documents. The situation i had was that i were serving a larger wsdl over
PHP (which serves documents with Transfer-Encoding: chunked). 

This is probably related to this bug (which i originally hit):

http://bugs.php.net/bug.php?id=47021

The reason why this affects SOAP is because the default mechanism to fetch
wsdl files changed in PHP 5.3. In PHP 5.2 it fetched documents using HTTP
1.0. Now it is HTTP 1.1.

The attached patch fixes this.

Reproduce code:
---------------
$length=1600;
$streams[]="data://text/plain,".dechex($length*10)."\r\n".str_repeat("1234567890",$length)."\r\n5\r\n00000\r\n0\r\n";
foreach ($streams as $name) {
        $fp = fopen($name, "r");
        stream_filter_append($fp, "dechunk", STREAM_FILTER_READ);
        var_dump(stream_get_contents($fp));
        fclose($fp);
}


Expected result:
----------------
Too much to post here and should be obvious

Actual result:
--------------
Some broken string (smaller than expected and thus wrong)

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

Reply via email to