[glib] gdbus: Check signature of NameAcquired, NameLost



commit 7c97e3d784f7243d6a426f1c5659cbccc6acb139
Author: Simon McVittie <smcv collabora com>
Date:   Mon Jun 19 12:47:50 2017 +0100

    gdbus: Check signature of NameAcquired, NameLost
    
    Calling g_variant_get (parameters, "(&s)") when parameters has a
    signature other than (s) is considered to be a programming error.
    In practice the message bus (dbus-daemon or a reimplementation) should
    always send the expected type, but be defensive.
    
    (Modified by Philip Withnall to improve type check.)
    
    Signed-off-by: Simon McVittie <smcv collabora com>
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784392

 gio/gdbusnameowning.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c
index fcfc2f4..2c2714d 100644
--- a/gio/gdbusnameowning.c
+++ b/gio/gdbusnameowning.c
@@ -273,6 +273,13 @@ on_name_lost_or_acquired (GDBusConnection  *connection,
       g_strcmp0 (sender_name, "org.freedesktop.DBus") != 0)
     goto out;
 
+  if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
+    {
+      g_warning ("%s signal had unexpected signature %s", signal_name,
+                 g_variant_get_type_string (parameters));
+      goto out;
+    }
+
   if (g_strcmp0 (signal_name, "NameLost") == 0)
     {
       g_variant_get (parameters, "(&s)", &name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]