Bug #70879 [NEW]: Content-Length with apache2handler may be limited to 2G

From: Date: Sun, 08 Nov 2015 14:14:51 +0000
Subject: Bug #70879 [NEW]: Content-Length with apache2handler may be limited to 2G
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197119@lists.php.net to get a copy of this message
From:             aharvey
Operating system: Linux (32 bit)
PHP version:      5.6Git-2015-11-08 (Git)
Package:          Apache2 related
Bug Type:         Bug
Bug description:Content-Length with apache2handler may be limited to 2G

Description:
------------
Under the apache2handler SAPI, setting a Content-Length header via
header() with a value beyond LONG_MAX will result in the value being
truncated to LONG_MAX, even when the apr_off_t type allows for a larger
value, due to the unconditional use of strtol() in
php_apache_sapi_header_handler() on non-Windows platforms.

To fix this, we should check sizeof(apr_off_t) and call strtoll() as
appropriate.

Test script:
---------------
<?php
header('Content-Length: 4294967296');
header('Content-Type: application/octet-stream');
$fp = fopen('/dev/zero', 'rb');
fpassthru($fp);
fclose($fp);
?>

Place in an Apache 2 handler environment, and then use curl -I to send a
HEAD request and get the headers.

Expected result:
----------------
HTTP/1.1 200 OK
Date: Sun, 08 Nov 2015 14:11:19 GMT
Server: Apache/2.4.7 (Ubuntu) PHP/5.6.16-dev
X-Powered-By: PHP/5.6.16-dev
Content-Length: 4294967296
Content-Type: application/octet-stream

Actual result:
--------------
HTTP/1.1 200 OK
Date: Sun, 08 Nov 2015 14:03:35 GMT
Server: Apache/2.4.7 (Ubuntu) PHP/5.6.16-dev
X-Powered-By: PHP/5.6.16-dev
Content-Length: 2147483647
Content-Type: application/octet-stream

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70879&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70879&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70879&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70879&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70879&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70879&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70879&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70879&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70879&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70879&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70879&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70879&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70879&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70879&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70879&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70879&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70879&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70879&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70879&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70879&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70879&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#197119) next »