File libfm-1.2.3-Fix-SF953.patch of Package libfm
From 8df4f66621a21c45e562c36a27039e63be07f27a Mon Sep 17 00:00:00 2001
From: Andriy Grytsenko <andrej@rep.kiev.ua>
Date: Sun, 10 May 2015 18:34:34 +0300
Subject: [PATCH] [SF#953] Fix crash in expand_exec_macros() on missing Exec
line in desktop entry.
---
NEWS | 2 ++
src/base/fm-app-info.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/NEWS b/NEWS
index 60c45ab..dee4a17 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@
* Fixed issues on dropping folders into Places for bookmarking them.
+* Fixed crash in expand_exec_macros() on missing Exec line.
+
Changes on 1.2.3 since 1.2.2:
diff --git a/src/base/fm-app-info.c b/src/base/fm-app-info.c
index 5bd4433..6dc2cc5 100644
--- a/src/base/fm-app-info.c
+++ b/src/base/fm-app-info.c
@@ -2,6 +2,7 @@
* fm-app-info.c
*
* Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+ * Copyright 2012-2015 Andriy Grytsenko (LStranger) <andrej@rep.kiev.ua>
*
* This file is a part of the Libfm library.
*
@@ -88,6 +89,8 @@ static char* expand_exec_macros(GAppInfo* app, const char* full_desktop_path,
GFile *file = NULL;
GList *fl = NULL;
+ if (exec == NULL)
+ return NULL;
cmd = g_string_sized_new(1024);
for(p = exec; *p; ++p)
{
@@ -134,6 +137,8 @@ static char* expand_exec_macros(GAppInfo* app, const char* full_desktop_path,
g_string_append_c(cmd, '%');
break;
case 'i':
+ if (kf == NULL)
+ break;
{
char* icon_name = g_key_file_get_locale_string(kf, "Desktop Entry",
"Icon", NULL, NULL);
@@ -258,6 +263,15 @@ static gboolean do_launch(GAppInfo* appinfo, const char* full_desktop_path,
GPid pid;
cmd = expand_exec_macros(appinfo, full_desktop_path, kf, inp, &gfiles);
+ if (cmd == NULL || cmd[0] == '\0')
+ {
+ g_free(cmd);
+ /* FIXME: localize the string below in 1.3.0 */
+ g_set_error_literal(err, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Desktop entry contains no valid Exec line");
+ return FALSE;
+ }
+ /* FIXME: do check for TryExec/Exec */
if(G_LIKELY(kf))
use_terminal = g_key_file_get_boolean(kf, "Desktop Entry", "Terminal", NULL);
else
--
2.1.4