Skip to content

Init encryption module before calculating unencrypted block-size#40240

Merged
butonic merged 1 commit intomasterfrom
begin-before-getsize
Jul 27, 2022
Merged

Init encryption module before calculating unencrypted block-size#40240
butonic merged 1 commit intomasterfrom
begin-before-getsize

Conversation

@IljaN
Copy link
Copy Markdown
Contributor

@IljaN IljaN commented Jul 26, 2022

Description

Fixes a bug where the un-encrypted blocksize was calculated before initializing the encryption-module. This yields the wrong size after a file-scan. The issue is only triggered if encryption.use_legacy_encoding is set to true.

Related Issue

Related test PR: owncloud/encryption#360 (comment)

Motivation and Context

When restoring encrypted files from backup and doing a occ file:scan --repair and encryption:fix-encrypted-version the file was still not readable correctly because the size in oc_filecache is wrong.

The wrong calculation was introduced via #38249 where the size calculation depends on the encoding mode (binary vs base64). The code assumes that the begin method is called before the size is calculated which is not the case for the call-site which this PR fixes.

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@IljaN IljaN self-assigned this Jul 26, 2022
@update-docs
Copy link
Copy Markdown

update-docs bot commented Jul 26, 2022

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@IljaN IljaN marked this pull request as ready for review July 26, 2022 15:19
@micbar
Copy link
Copy Markdown
Contributor

micbar commented Jul 26, 2022

Nice catch!

@IljaN IljaN requested review from butonic and jvillafanez July 27, 2022 07:33
@butonic butonic merged commit 75b3cab into master Jul 27, 2022
@delete-merged-branch delete-merged-branch bot deleted the begin-before-getsize branch July 27, 2022 07:33
@phil-davis
Copy link
Copy Markdown
Contributor

@IljaN @butonic what to do about a changelog in core?
What can be written about this from the PoV of core?

@IljaN
Copy link
Copy Markdown
Contributor Author

IljaN commented Jul 27, 2022

@phil-davis I'll take care, merged a bit too early. Sorry.

IljaN added a commit that referenced this pull request Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants