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

From: Date: Sun, 08 Nov 2015 14:15:17 +0000
Subject: Bug #70879 [Opn->Asn]: Content-Length with apache2handler may be limited to 2G
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197120@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70879&edit=1

 ID:                 70879
 Updated by:         aharvey@php.net
 Reported by:        aharvey@php.net
 Summary:            Content-Length with apache2handler may be limited to
                     2G
-Status:             Open
+Status:             Assigned
 Type:               Bug
 Package:            Apache2 related
 Operating System:   Linux (32 bit)
 PHP Version:        5.6Git-2015-11-08 (Git)
-Assigned To:        
+Assigned To:        aharvey
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2015-11-08 14:14:49] aharvey@php.net

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 this bug report at https://bugs.php.net/bug.php?id=70879&edit=1


Thread (3 messages)

« previous php.bugs (#197120) next »