summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-12 16:05:03 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-02-07 11:23:28 +0100
commite156f8339cec0ae97ed62344ce1f186600b6b909 (patch)
treedd874b1ccc2079184ace112445f235d33669f8b3 /lib/private/legacy
parent3885818ab67f941a54d8b186945399e55c9ac6fe (diff)
downloadnextcloud-server-e156f8339cec0ae97ed62344ce1f186600b6b909.tar.gz
nextcloud-server-e156f8339cec0ae97ed62344ce1f186600b6b909.zip
Revert "remove 32-bit workarounds"
This reverts commit dd8774389e21b59c07882580356d51de018fe867. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_Response.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/legacy/OC_Response.php b/lib/private/legacy/OC_Response.php
index b849710e90b..e4525fe9e10 100644
--- a/lib/private/legacy/OC_Response.php
+++ b/lib/private/legacy/OC_Response.php
@@ -52,6 +52,19 @@ class OC_Response {
* @param string|int|float $length Length to be sent
*/
public static function setContentLengthHeader($length) {
+ if (PHP_INT_SIZE === 4) {
+ if ($length > PHP_INT_MAX && stripos(PHP_SAPI, 'apache') === 0) {
+ // Apache PHP SAPI casts Content-Length headers to PHP integers.
+ // This enforces a limit of PHP_INT_MAX (2147483647 on 32-bit
+ // platforms). So, if the length is greater than PHP_INT_MAX,
+ // we just do not send a Content-Length header to prevent
+ // bodies from being received incompletely.
+ return;
+ }
+ // Convert signed integer or float to unsigned base-10 string.
+ $lfh = new \OC\LargeFileHelper;
+ $length = $lfh->formatUnsignedInteger($length);
+ }
header('Content-Length: '.$length);
}