File 0015-Restrict-CopyFileData-to-writing-to-already-existing-files.patch of Package kpmcore

From 81a5eae665130b01dcd7bc92deea188d03ad7e35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <andrius@stikonas.eu>
Date: Sat, 5 Feb 2022 14:12:38 +0000
Subject: [PATCH] Restrict CopyFileData to writing to already existing files.

---
 src/util/externalcommandhelper.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp
index 9bdc527..665e4da 100644
--- a/src/util/externalcommandhelper.cpp
+++ b/src/util/externalcommandhelper.cpp
@@ -179,6 +179,11 @@ QVariantMap ExternalCommandHelper::CopyFileData(const QString& sourceDevice, con
         return {};
     }
 
+    // Only allow writing to existing files.
+    if(!std::filesystem::exists(targetPath)) {
+        return {};
+    }
+
     QVariantMap reply;
     reply[QStringLiteral("success")] = true;
 
-- 
GitLab

openSUSE Build Service is sponsored by