From 8fb8c9a3ef068cb662975b6aa8d5b5f69a07bea1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Apr 2011 16:25:15 +0100 Subject: [PATCH 14/15] get_all_object_properties: if _dbus_gvalue_marshal fails, bail out This isn't necessarily OOM: _dbus_gvalue_marshal can fail due to programming errors. If so, raise a critical warning, then (if that wasn't fatal) return a D-Bus error to be sent to the caller. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=35766 --- dbus/dbus-gobject.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index 61aed9a..78c0cf8 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -1324,8 +1324,32 @@ get_all_object_properties (DBusConnection *connection, &iter_dict_value)) goto oom; + g_free (variant_sig); + + /* this can fail via programming error: the GObject property was + * malformed (non-UTF8 string or something) */ if (!_dbus_gvalue_marshal (&iter_dict_value, &value)) - goto oom; + { + gchar *contents = g_strdup_value_contents (&value); + gchar *error_message = g_strdup_printf ( + "cannot GetAll(%s): failed to serialize %s value of type %s: %s", + wincaps_propiface, prop_name, G_VALUE_TYPE_NAME (&value), + contents); + + g_critical ("%s", error_message); + + /* abandon ship! */ + dbus_message_iter_abandon_container (&iter_dict_entry, + &iter_dict_value); + dbus_message_iter_abandon_container (&iter_dict, &iter_dict_entry); + dbus_message_unref (ret); + ret = error_or_die (message, DBUS_ERROR_FAILED, error_message); + + g_free (contents); + g_free (error_message); + g_value_unset (&value); + return ret; + } /* these shouldn't fail except by OOM now that we were successful */ if (!dbus_message_iter_close_container (&iter_dict_entry, @@ -1335,7 +1359,6 @@ get_all_object_properties (DBusConnection *connection, goto oom; g_value_unset (&value); - g_free (variant_sig); } if (!dbus_message_iter_close_container (&iter_ret, &iter_dict)) -- 1.7.4.1