From 389424c54b9f46c44dca4e736c3d0e3aa0f3b522 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 7 Dec 2021 11:33:43 +0100 Subject: [PATCH] avoid downloading a file from server when modified time is invalid Signed-off-by: Matthieu Gallien --- src/libsync/propagatedownload.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 7b17c364c..b06a4d115 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -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); -- 2.30.2