|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52679 Content-length header is limited to 32bit integer
Submitted: 2010-08-23 21:24 UTC Modified: 2021-07-20 13:03 UTC
Avg. Score:4.5 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:1 (12.5%)
From: dominic dot benson at thirdlight dot com Assigned: cmb (profile)
Status: Closed Package: Apache2 related
PHP Version: 5.3.3 OS: Linux 32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: dominic dot benson at thirdlight dot com
New email:
PHP Version: OS:


 [2010-08-23 21:24 UTC] dominic dot benson at thirdlight dot com
As per #51723, the content-length header is limited to 2GB - however it need not be.
If Apache 2.2 is built with -DLARGEFILE_SOURCE -DFILE_OFFSET_BITS=64 then apr_off_t is an off64_t, however the conversion in the calls to ap_set_content_length uses strtocol (hence limited to the 32-bit long on Linux 32), but if strtocoll is used instead to return a 64-bit long long, the header is set correctly for values > 2GB.

The attached patch is of the adjustment, I guess the configure script generation needs to be updated to establish whether apr_off_t is long or long long.

Test script:
header("Content-Length: 10000000000");

Expected result:
A header:
Content-Length: 10000000000

Actual result:
A header:
Content-Length: 2147483647


big-content-length.patch (last revision 2010-08-23 19:48 UTC by dominic dot benson at thirdlight dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-23 21:49 UTC] dominic dot benson at thirdlight dot com
Correction to the above - clearly I mean strtol and strtoll rather than strtocol and strtocoll.
 [2010-08-24 13:17 UTC]
strtoll is not portable. We need something like in to define it. Probably php-src/main/ should declare a php_strtoll or so. (Didn't take a closer look at the issue)
 [2010-08-24 13:32 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-08-24 13:32 UTC]
Exactly, will add it while testing the other fix (which works on windows 32/64 and linux 64 only so far) more carefully.
 [2017-10-24 07:32 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2021-07-20 13:03 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-07-20 13:03 UTC]
This is implemented as of PHP 5.6.18[1].

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Aug 04 19:01:26 2021 UTC