From: Matthieu Gallien Date: Tue, 7 Dec 2021 10:25:43 +0000 (+0100) Subject: prevent invalid modified time from being propagated X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~253^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c9f63b5744ac598c701b0516db8686a6609bea14;p=nextcloud-desktop.git prevent invalid modified time from being propagated Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/bulkpropagatorjob.cpp b/src/libsync/bulkpropagatorjob.cpp index 6130bd7f7..9650bfa18 100644 --- a/src/libsync/bulkpropagatorjob.cpp +++ b/src/libsync/bulkpropagatorjob.cpp @@ -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; diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index e74c49c90..b86f737e5 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -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;