Skip to content

Commit

Permalink
Merge pull request #5568 from nextcloud/bugfix/sortBeforeComputingChe…
Browse files Browse the repository at this point in the history
…cksum

sort encrypted files by their id to compute checksum
  • Loading branch information
mgallien authored Apr 4, 2023
2 parents 3ffdb9b + a76d9fe commit 27f46eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,11 @@ QByteArray FolderMetadata::computeMetadataKeyChecksum(const QByteArray &metadata
auto hashAlgorithm = QCryptographicHash{QCryptographicHash::Sha256};

hashAlgorithm.addData(_account->e2e()->_mnemonic.remove(' ').toUtf8());
for (const auto &singleFile : _files) {
auto sortedFiles = _files;
std::sort(sortedFiles.begin(), sortedFiles.end(), [] (const auto &first, const auto &second) {
return first.encryptedFilename < second.encryptedFilename;
});
for (const auto &singleFile : sortedFiles) {
hashAlgorithm.addData(singleFile.encryptedFilename.toUtf8());
}
hashAlgorithm.addData(metadataKey);
Expand Down

0 comments on commit 27f46eb

Please sign in to comment.