prevent invalid modified time from being propagated
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 7 Dec 2021 10:25:43 +0000 (11:25 +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/bulkpropagatorjob.cpp
src/libsync/propagateupload.cpp

index 6130bd7f73c74d248c58d1aae365831a4ac0328a..9650bfa187329eb80225db762381a27fec2d69a5 100644 (file)
@@ -275,6 +275,9 @@ void BulkPropagatorJob::slotStartUpload(SyncFileItemPtr item,
     // have been changed again, so better check again here.
 
     item->_modtime = FileSystem::getModTime(originalFilePath);
+    if (item->_modtime <= 0) {
+        return slotOnErrorStartFolderUnlock(item, SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
+    }
     if (prevModtime != item->_modtime) {
         propagator()->_anotherSyncNeeded = true;
         qDebug() << "trigger another sync after checking modified time of item" << item->_file << "prevModtime" << prevModtime << "Curr" << item->_modtime;
index e74c49c907902e8ad2579dc3a4b9c34d48e1ded9..b86f737e5e4cebf962a49d5037524bdb0fecdbdc 100644 (file)
@@ -385,12 +385,20 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh
     if (!FileSystem::fileExists(fullFilePath)) {
         return slotOnErrorStartFolderUnlock(SyncFileItem::SoftError, tr("File Removed (start upload) %1").arg(fullFilePath));
     }
+    if (_item->_modtime <= 0) {
+        return slotOnErrorStartFolderUnlock(
+            SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
+    }
     Q_ASSERT(_item->_modtime > 0);
     time_t prevModtime = _item->_modtime; // the _item value was set in PropagateUploadFile::start()
     // but a potential checksum calculation could have taken some time during which the file could
     // have been changed again, so better check again here.
 
     _item->_modtime = FileSystem::getModTime(originalFilePath);
+    if (_item->_modtime <= 0) {
+        return slotOnErrorStartFolderUnlock(
+            SyncFileItem::SoftError, tr("Local file has invalid modified time. Do not upload to the server."));
+    }
     Q_ASSERT(_item->_modtime > 0);
     if (prevModtime != _item->_modtime) {
         propagator()->_anotherSyncNeeded = true;