avoid downloading a file from server when modified time is invalid
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 7 Dec 2021 10:33:43 +0000 (11:33 +0100)
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>
Wed, 8 Dec 2021 07:22:24 +0000 (07:22 +0000)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagatedownload.cpp

index 7b17c364ca74dfad08db0dcfee044517bb315d91..b06a4d11591857bc39a22525a1cdf02ca0b8e702 100644 (file)
@@ -1063,11 +1063,19 @@ void PropagateDownloadFile::downloadFinished()
         return;
     }
 
+    if (_item->_modtime <= 0) {
+        done(SyncFileItem::NormalError, tr("File %1 has invalid modified time reported by server. Do not save it.").arg(QDir::toNativeSeparators(_item->_file)));
+        return;
+    }
     Q_ASSERT(_item->_modtime > 0);
     FileSystem::setModTime(_tmpFile.fileName(), _item->_modtime);
     // We need to fetch the time again because some file systems such as FAT have worse than a second
     // Accuracy, and we really need the time from the file system. (#3103)
     _item->_modtime = FileSystem::getModTime(_tmpFile.fileName());
+    if (_item->_modtime <= 0) {
+        done(SyncFileItem::NormalError, tr("File %1 has invalid modified time reported by server. Do not save it.").arg(QDir::toNativeSeparators(_item->_file)));
+        return;
+    }
     Q_ASSERT(_item->_modtime > 0);
 
     bool previousFileExists = FileSystem::fileExists(fn);