Have dbind_method_call_reentrant_va check the signature of replies
authorMike Gorse <mgorse@linux-l2tz.site>
Fri, 20 Jan 2012 18:55:40 +0000 (12:55 -0600)
committerMike Gorse <mgorse@linux-l2tz.site>
Fri, 20 Jan 2012 18:55:40 +0000 (12:55 -0600)
When making a method call, we should check that the signature of the
reply matches what we expect and throw an error if not. Otherwise we may
crash.

dbind/dbind.c

index 3989bb6..c2b6f5d 100644 (file)
@@ -153,6 +153,17 @@ dbind_method_call_reentrant_va (DBusConnection *cnx,
     {
         DBusMessageIter iter;
         dbus_message_iter_init (reply, &iter);
+       if (strcmp (p + 2, dbus_message_get_signature (reply)) != 0)
+       {
+           g_warning ("dbind: Call to \"%s\" returned signature %s; expected %s",
+                      method, p + 2, dbus_message_get_signature (reply));
+           if (opt_error)
+               dbus_set_error (opt_error, DBUS_ERROR_INVALID_ARGS,
+                               "Call to \"%s\" returned signature %s; expected %s",
+                               method, p + 2,
+                               dbus_message_get_signature (reply));
+           goto out;
+       }
         p = arg_types;
         dbind_any_demarshal_va (&iter, &p, args_demarshal);
     }