]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
sort encrypted files by their id to compute checksum
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 4 Apr 2023 12:54:12 +0000 (14:54 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Tue, 4 Apr 2023 13:06:05 +0000 (15:06 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/clientsideencryption.cpp

index ca805835145fb82d470273cf00d1fdcfb3dd84d0..4dfc3c6d3a7fc87347e981e9daab7a52fba14bdb 100644 (file)
@@ -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);