From e156f8339cec0ae97ed62344ce1f186600b6b909 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 12 Jan 2023 16:05:03 +0100 Subject: Revert "remove 32-bit workarounds" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dd8774389e21b59c07882580356d51de018fe867. Signed-off-by: Côme Chilliet --- lib/private/legacy/OC_Response.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/private/legacy') 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); } -- cgit v1.2.3