Skip to content

fix(encryption): Increment lastChunkNr when size is off - #55981

Merged
artonge merged 1 commit into
masterfrom
artonge/fix/encryption/increment_lastChunkNr
Nov 25, 2025
Merged

fix(encryption): Increment lastChunkNr when size is off#55981
artonge merged 1 commit into
masterfrom
artonge/fix/encryption/increment_lastChunkNr

Conversation

@artonge

Copy link
Copy Markdown
Collaborator

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.

@artongeartonge changed the title fix(encryption): Increment lastChunkNr when size is offfix(encryption): Increment lastChunkNr when size is offOct 28, 2025
@artonge
artonge marked this pull request as ready for review November 19, 2025 12:41
@artonge
artonge requested a review from a team as a code ownerNovember 19, 2025 12:41
@artonge
artonge requested review from leftybournes, provokateurin, salmart-dev and yemkareems and removed request for a teamNovember 19, 2025 12:41
@artongeartonge self-assigned this Nov 19, 2025
@artongeartonge added bug 3. to review Waiting for reviews feature: encryption (server-side) php Pull requests that update Php code labels Nov 19, 2025
@artongeartonge added this to the Nextcloud 33 milestone Nov 19, 2025
@artonge

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable32

@artonge

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable31

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 <louis@chmn.me>
@artonge
artongeforce-pushed the artonge/fix/encryption/increment_lastChunkNr branch from 10b8610 to 30d567fCompareNovember 21, 2025 16:34
@artonge
artonge merged commit 0b30415 into masterNov 25, 2025
219 of 228 checks passed
@artonge
artonge deleted the artonge/fix/encryption/increment_lastChunkNr branch November 25, 2025 09:18
@nextcloud-botnextcloud-bot mentioned this pull request Jan 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbugfeature: encryption (server-side)phpPull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@artonge@provokateurin@come-nc