Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release-src > by-pkgid > efab0889861377768d39f75e98881cd4 > files > 3

gnome-session-3.14.0-6.mga5.src.rpm

From 3442740ad4808f91fb857fb2dda3c24992f0bbdf Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Fri, 14 Nov 2014 09:49:21 -0500
Subject: autostart: validate autostart condition gsettings key

gnome-session will crash if fed a desktop file with an
autostart condition that references an invalid key for
a given schema.

This commit validates that the key associated with the
autostart condition is defined in the schema and defined
to have a boolean type.

https://bugzilla.gnome.org/show_bug.cgi?id=740119

diff --git a/gnome-session/gsm-autostart-app.c b/gnome-session/gsm-autostart-app.c
index 21a6004..437fb0c 100644
--- a/gnome-session/gsm-autostart-app.c
+++ b/gnome-session/gsm-autostart-app.c
@@ -337,12 +337,16 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app,
         GSettingsSchemaSource *source;
         GSettingsSchema *schema;
         GSettings *settings;
+        GSettingsSchemaKey *schema_key;
+        const GVariantType *key_type;
         char **elems;
         gboolean retval = FALSE;
         char *signal;
 
         retval = FALSE;
 
+        schema = NULL;
+
         elems = g_strsplit (key, " ", 2);
 
         if (elems == NULL)
@@ -358,9 +362,24 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app,
         if (schema == NULL)
                 goto out;
 
+        if (!g_settings_schema_has_key (schema, elems[1]))
+                goto out;
+
+        schema_key = g_settings_schema_get_key (schema, elems[1]);
+
+        g_assert (schema_key != NULL);
+
+        key_type = g_settings_schema_key_get_value_type (schema_key);
+
+        g_settings_schema_key_unref (schema_key);
+
+        g_assert (key_type != NULL);
+
+        if (!g_variant_type_equal (key_type, G_VARIANT_TYPE_BOOLEAN))
+                goto out;
+
         settings = g_settings_new_full (schema, NULL, NULL);
         retval = g_settings_get_boolean (settings, elems[1]);
-        g_settings_schema_unref (schema);
 
         signal = g_strdup_printf ("changed::%s", elems[1]);
         g_signal_connect (G_OBJECT (settings), signal,
@@ -370,6 +389,8 @@ setup_gsettings_condition_monitor (GsmAutostartApp *app,
         app->priv->condition_settings = settings;
 
 out:
+        if (schema)
+                g_settings_schema_unref (schema);
         g_strfreev (elems);
 
         return retval;
-- 
cgit v0.10.2