summaryrefslogtreecommitdiff
path: root/kde-frameworks/kio/files/kio-5.113.0-fix-crash-malformed-exec.patch
blob: 3688fa4af276226da01141f322b762e13dc17fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From ebad60218b9d9e6901ae48c3dec9b90da963809c Mon Sep 17 00:00:00 2001
From: Harald Sitter <sitter@kde.org>
Date: Wed, 13 Dec 2023 07:44:01 +0100
Subject: [PATCH] kpropertiesdialog: don't trip over malformed Exec

when the user incorrectly put env vars into the Program field the
resulting desktop file will be somewhat malformed and literally contain

> Exec='FOO=1 Bar'

this then needs careful handling when parsing so we don't accidentally
drain the execline list. when this scenario appears we'll need to assume
the last item in the list is the program as we can't really tell if it
is a program that looks like an env var or an env var without program

BUG: 465290
(cherry picked from commit 78d4364677fbe658c6e05d19bb158f895403ccc9)
---
 src/widgets/kpropertiesdialog.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/widgets/kpropertiesdialog.cpp b/src/widgets/kpropertiesdialog.cpp
index 93ec0759cf..25061825af 100644
--- a/src/widgets/kpropertiesdialog.cpp
+++ b/src/widgets/kpropertiesdialog.cpp
@@ -3379,6 +3379,12 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *_props)
             execLine.pop_front();
         }
         for (auto env : execLine) {
+            if (execLine.length() <= 1) {
+                // Don't empty out the list. If the last element contains an equal sign we have to treat it as part of the
+                // program name lest we have no program
+                // https://bugs.kde.org/show_bug.cgi?id=465290
+                break;
+            }
             if (!env.contains(QLatin1String("="))) {
                 break;
             }
-- 
GitLab