From 222d342b72d27a554f53b9a021493d68a1905e91 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 5 May 2010 13:31:38 +0200 Subject: [PATCH 3/7] Check that a maybe has none or one element --- dbus/dbus-message.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 55b34b2..8a94c51 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -887,6 +887,14 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, _dbus_assert (i == n_elements); _dbus_assert (str_array[i] == NULL); + if (spec_type == DBUS_TYPE_MAYBE && _DBUS_UNLIKELY (n_elements > 1)) + { + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Maybe \"%s\" contains multiple elements\n", + _dbus_type_to_string (spec_element_type)); + goto out; + } + *str_array_p = str_array; *n_elements_p = n_elements; } @@ -2685,6 +2693,11 @@ dbus_message_iter_open_container (DBusMessageIter *iter, (contained_signature == NULL || _dbus_check_is_valid_signature (contained_signature)), FALSE); + /* the containted signature of a maybe must contain exactly one element */ + _dbus_return_val_if_fail (((type == DBUS_TYPE_MAYBE && + (contained_signature[0] != '\0' && + contained_signature[1] == '\0')) || + type != DBUS_TYPE_MAYBE), FALSE); if (!_dbus_message_iter_open_signature (real)) return FALSE; -- 1.7.1