From a76d9fe46dde4d9f26adc09456e0863d9c2a356c Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 4 Apr 2023 14:54:12 +0200 Subject: [PATCH] sort encrypted files by their id to compute checksum Signed-off-by: Matthieu Gallien --- src/libsync/clientsideencryption.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index ca805835145fb..4dfc3c6d3a7fc 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -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);