From 729669e43dda934b798b4a24b01f02ebeec1e1bc Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 29 Jul 2014 11:16:47 +0100 Subject: [PATCH 2/2] demarshal_static_variant: fail gracefully with unknown message types Refuse to demarshal variants containing unknown types such as DBUS_TYPE_UNIX_FD or DBUS_TYPE_MAYBE. Otherwise we will not be able to free them automatically with g_value_unset. Symptoms: > GLib-GObject-CRITICAL **: g_value_unset: assertion 'G_IS_VALUE (value)' failed https://bugs.freedesktop.org/show_bug.cgi?id=80557 --- dbus/dbus-gvalue.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 7f1fc89..6641618 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -647,17 +647,24 @@ demarshal_static_variant (DBusGValueMarshalCtx *context, sig = dbus_message_iter_get_signature (&subiter); variant_type = _dbus_gtype_from_signature (sig, context->proxy != NULL); - if (variant_type != G_TYPE_INVALID) + if (variant_type == G_TYPE_INVALID) { - g_value_init (value, variant_type); - - if (!_dbus_gvalue_demarshal (context, &subiter, value, error)) - { - dbus_free (sig); - return FALSE; - } + /* It can happen if we received an unknown type such as + * DBUS_TYPE_UNIX_FD or DBUS_TYPE_MAYBE. */ + g_set_error (error, DBUS_GERROR, + DBUS_GERROR_INVALID_SIGNATURE, + "Variant contains unknown signature \'%s\'", sig); + dbus_free (sig); + return FALSE; } + dbus_free (sig); + + g_value_init (value, variant_type); + + if (!_dbus_gvalue_demarshal (context, &subiter, value, error)) + return FALSE; + return TRUE; } -- 1.8.5.3