edbus: Fix type check of solo structs
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>
Tue, 16 Oct 2012 22:35:50 +0000 (22:35 +0000)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 16 Oct 2012 22:35:50 +0000 (22:35 +0000)
When reading messages that contain structs the type that comes from the
wire (and obtained with dbus_message_iter_get_arg_type()) is 'r'.
However 'r' never appears in a signature and dbus_signature_iter_*
returns '('.

Ref: http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures

"STRUCT has a type code, ASCII character 'r', but this type code does not
appear in signatures. Instead, ASCII characters '(' and ')' are used to
mark the beginning and end of the struct. So for example, a struct
containing two integers would have this signature:"

Patch by: José Roberto de Souza  <zehortigoza@profusion.mobi>

SVN revision: 78072

src/lib/edbus_message.c

index fcbdb57..3b18c41 100644 (file)
@@ -705,7 +705,12 @@ edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signatur
 
         dbus_free(iter_sig);
         dbus_signature_iter_next(&signature_iter);
-        EINA_SAFETY_ON_FALSE_RETURN_VAL(c == current_type, EINA_FALSE);
+
+        if ((c != current_type) && !(current_type == 'r' && c == '('))
+          {
+             ERR("Type in iterator different of signature");
+             return EINA_FALSE;
+          }
 
         if (dbus_type_is_basic(current_type))
           get_basic(current_type, &iter->dbus_iterator, MAKE_PTR_FROM_VA_LIST(ap));