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
This commit is contained in:
Simon McVittie 2017-06-19 12:47:50 +01:00 committed by Philip Withnall
parent c53b44edb2
commit 7c97e3d784

View File

@ -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);