From 8afe1dd53a3e8e6a29e253117b13528e534ca597 Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Fri, 24 Oct 2025 13:44:24 +0200 Subject: [PATCH] fix(encryption): Increment lastChunkNr when size is off When computing the unencrypted file size, we need the size of the last encrypted chunk as its size is usually not the regular 8192 bits. To avoid reading the whole file, we seek directly to that last chunk based on the expected file size. When the expected file size is smaller than the actual one, we have a logic in place to continue reading until we reach the end of the file. In that logic, we forgot to increment the `$lastChunkNr` which is important when we later check the signature of the chunk. This commit adds that missing increment. Signed-off-by: Louis Chmn --- lib/private/Files/Storage/Wrapper/Encryption.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 03d4038186fef..465971d1345b7 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -464,6 +464,7 @@ protected function fixUnencryptedSize(string $path, int $size, int $unencryptedS if (strlen($lastChunkContentEncrypted) > $blockSize) { $newUnencryptedSize += $unencryptedBlockSize; $lastChunkContentEncrypted = substr($lastChunkContentEncrypted, $blockSize); + $lastChunkNr++; } }