From fc4e0501f03de66eafb0a3a2d04024a40be17756 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 30 Jan 2018 14:22:31 +0100 Subject: [PATCH] Fix integer overflow in ChunkingPlugin Avoids errors when the size exceeds MAX_INT because of the cast to int. Better cast it to float to avoid this. Signed-off-by: Morris Jobke --- apps/dav/lib/Upload/ChunkingPlugin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php index a3f6e528c6..421a2dd519 100644 --- a/apps/dav/lib/Upload/ChunkingPlugin.php +++ b/apps/dav/lib/Upload/ChunkingPlugin.php @@ -97,7 +97,10 @@ class ChunkingPlugin extends ServerPlugin { return; } $actualSize = $this->sourceNode->getSize(); - if ((int)$expectedSize !== $actualSize) { + + // casted to string because cast to float cause equality for non equal numbers + // and integer has the problem of limited size on 32 bit systems + if ((string)$expectedSize !== (string)$actualSize) { throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); } }