From 64fed0c712f803f943520ea62ded0315dc6f838c 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 ac83d90f81ad6..380ec0f253008 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++; } }