From: Matthieu Gallien Date: Tue, 7 Dec 2021 13:44:08 +0000 (+0100) Subject: prevent injecting invalid modified time through CfApi calls X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~253^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b1977dfb1890f7e583f268c215eff3a02671fa4e;p=nextcloud-desktop.git prevent injecting invalid modified time through CfApi calls Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 09fb3764a..16b9d8f7e 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -643,6 +643,10 @@ OCC::Result OCC::CfApiWrapper::se OCC::Result OCC::CfApiWrapper::createPlaceholderInfo(const QString &path, time_t modtime, qint64 size, const QByteArray &fileId) { + if (modtime <= 0) { + return {QString{"Could not update metadata due to invalid modified time for %1: %2"}.arg(path).arg(modtime)}; + } + const auto fileInfo = QFileInfo(path); const auto localBasePath = QDir::toNativeSeparators(fileInfo.path()).toStdWString(); const auto relativePath = fileInfo.fileName().toStdWString(); @@ -691,6 +695,10 @@ OCC::Result OCC::CfApiWrapper::up { Q_ASSERT(handle); + if (modtime <= 0) { + return {QString{"Could not update metadata due to invalid modified time for %1: %2"}.arg(pathForHandle(handle)).arg(modtime)}; + } + const auto info = replacesPath.isEmpty() ? findPlaceholderInfo(handle) : findPlaceholderInfo(handleForPath(replacesPath)); if (!info) {