prevent crash by catching more exception types from c++ std lib
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 18 Dec 2024 11:04:47 +0000 (12:04 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 2 Jan 2025 09:50:46 +0000 (09:50 +0000)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/common/filesystembase.cpp
src/libsync/propagatedownload.cpp

index 8371cc336097d908b21f6813c067a6dd7e097890..af9e19cb65bd1aae126555e36ac5efe54389671d 100644 (file)
@@ -131,6 +131,14 @@ void FileSystem::setFileReadOnly(const QString &filename, bool readonly)
         {
             qCWarning(lcFileSystem()) << filename << (readonly ? "readonly" : "read write") << e.what();
         }
+        catch (std::system_error e)
+        {
+            qCWarning(lcFileSystem()) << filename << e.what();
+        }
+        catch (...)
+        {
+            qCWarning(lcFileSystem()) << filename;
+        }
         return;
     }
 #endif
@@ -176,6 +184,14 @@ bool FileSystem::setFileReadOnlyWeak(const QString &filename, bool readonly)
         {
             qCWarning(lcFileSystem()) << filename << (readonly ? "readonly" : "read write") << e.what();
         }
+        catch (std::system_error e)
+        {
+            qCWarning(lcFileSystem()) << filename << e.what();
+        }
+        catch (...)
+        {
+            qCWarning(lcFileSystem()) << filename;
+        }
         return false;
     }
 #endif
@@ -468,6 +484,14 @@ bool FileSystem::isWritable(const QString &filename, const QFileInfo &fileInfo)
         {
             qCWarning(lcFileSystem()) << filename << e.what();
         }
+        catch (std::system_error e)
+        {
+            qCWarning(lcFileSystem()) << filename << e.what();
+        }
+        catch (...)
+        {
+            qCWarning(lcFileSystem()) << filename;
+        }
         return false;
     }
 #endif
@@ -494,6 +518,14 @@ bool FileSystem::isReadable(const QString &filename, const QFileInfo &fileInfo)
         {
             qCWarning(lcFileSystem()) << filename << e.what();
         }
+        catch (std::system_error e)
+        {
+            qCWarning(lcFileSystem()) << filename << e.what();
+        }
+        catch (...)
+        {
+            qCWarning(lcFileSystem()) << filename;
+        }
         return false;
     }
 #endif
index b6474ea54df9ecf5a51f3ce93a7c1df0b4b1f5e5..b3fd1174a4a092f4c68cd6fb04746db8c35a434b 100644 (file)
@@ -1223,6 +1223,14 @@ void PropagateDownloadFile::downloadFinished()
         {
             qCWarning(lcPropagateDownload()) << _item->_instruction << _item->_file << e.what();
         }
+        catch (std::system_error e)
+        {
+            qCWarning(lcPropagateDownload()) << _item->_instruction << _item->_file << e.what();
+        }
+        catch (...)
+        {
+            qCWarning(lcPropagateDownload()) << _item->_instruction << _item->_file;
+        }
 #else
         if (existingFile.permissions() != _tmpFile.permissions()) {
             _tmpFile.setPermissions(existingFile.permissions());