From: nachms+php at gmail dot com Operating system: Linux PHP version: 5.4.11 Package: Streams related Bug Type: Bug Bug description:CGI/FastCGI truncates input to modulo 4GB
Description: ------------ I've tested sending huge amounts of data via PUT to PHP from 5.3.x through 5.4.x via CGI, FastCGI, and mod_php for Apache, all on AMD64. In all my tests, mod_php with Apache seems to be fine. However via CGI or FastCGI, PHP can only see the amount of data modulo 4294967296. Which seems to indicate that somewhere an int instead of a long is used in the the CGI processing code, but so far, I have been unable to find where exactly. All my builds are 64-bit, so that's not the issue. To elaborate, via mod_php, if I send via HTTP PUT 4296015872 bytes, then PHP will see all of them. However, via CGI or FastCGI, PHP will only see 1048576 bytes. Test script: --------------- <?php print_r($_SERVER); //Print server variables so we can see Content-Length $amount = 0; $ifp = @fopen('php://input', 'rb'); if ($ifp) { while (!feof($ifp)) { set_time_limit(0); $buf = fread($ifp, 8192); if ($buf !== false) { $amount += strlen($buf); } } fclose($tfp); set_time_limit(0); echo 'Amount Read: ', $amount, "\n"; } //Test via HTTP (Apache): http://paste.nachsoftware.com/Nach/TXmPR8289646bbb54bf40ce295115111acde1eYP //Test via CGI (with FastCGI sharing results) http://paste.nachsoftware.com/Nach/MXNpV4ec2e499fc0941773aff51184e6e618d2lN Expected result: ---------------- When tested with either of my C test programs, I expect to see 4296015872 listed as the amount read. Actual result: -------------- With mod_php in Apache, I see 4296015872 which is correct. But with CGI/FastCGI, I see 1048576 as the amount read, which is 4296015872%4294967296, which indicates, somewhere a long is being converted to an int within the CGI/FastCGI code. -- Edit bug report at https://bugs.php.net/bug.php?id=64187&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64187&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64187&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64187&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64187&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64187&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64187&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64187&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64187&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64187&r=support Expected behavior: https://bugs.php.net/fix.php?id=64187&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64187&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64187&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64187&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64187&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64187&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64187&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64187&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64187&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64187&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64187&r=mysqlcfg