[at-spi2-core] Add some type checks for dbus messages, and remove some old code
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Add some type checks for dbus messages, and remove some old code
- Date: Tue, 27 Dec 2011 23:11:06 +0000 (UTC)
commit cc59ad948e990b60b9eb3e2154d704302f793d01
Author: Mike Gorse <mgorse novell com>
Date: Tue Dec 27 18:05:16 2011 -0500
Add some type checks for dbus messages, and remove some old code
Added a couple of message signature checks where it was still TODO (and
might have led to a crash if the wrong signature was sent). Also removed
some cases where two different signature types were accepted for API
compatibility reasons--the old API is no longer used.
registryd/de-marshaller.c | 7 -------
registryd/deviceeventcontroller.c | 26 ++++++--------------------
2 files changed, 6 insertions(+), 27 deletions(-)
---
diff --git a/registryd/de-marshaller.c b/registryd/de-marshaller.c
index 8b2b00f..4e0f2a5 100644
--- a/registryd/de-marshaller.c
+++ b/registryd/de-marshaller.c
@@ -87,17 +87,10 @@ dbus_bool_t spi_dbus_marshal_deviceEvent(DBusMessage *message, const Accessibili
dbus_bool_t spi_dbus_demarshal_deviceEvent(DBusMessage *message, Accessibility_DeviceEvent *e)
{
DBusMessageIter iter;
- dbus_uint16_t hw_code;
- dbus_uint16_t modifiers;
dbus_message_iter_init(message, &iter);
if (spi_dbus_message_iter_get_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT32, &e->hw_code, DBUS_TYPE_INT32, &e->modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID))
return TRUE;
- /* TODO: Perhaps remove the below code for 2.1 */
- if (!spi_dbus_message_iter_get_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT16, &hw_code, DBUS_TYPE_INT16, &modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID))
- return FALSE;
- e->hw_code = hw_code;
- e->modifiers = modifiers;
return TRUE;
}
diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c
index 07e5630..4910555 100644
--- a/registryd/deviceeventcontroller.c
+++ b/registryd/deviceeventcontroller.c
@@ -1910,13 +1910,14 @@ impl_register_keystroke_listener (DBusConnection *bus,
GSList *keys = NULL;
dbus_int32_t mask, type;
Accessibility_EventListenerMode *mode;
- dbus_bool_t ret;
+ dbus_bool_t ret;
DBusMessage *reply = NULL;
char *keystring;
- char *sig;
+
+ if (strcmp (dbus_message_get_signature (message), "oa(iisi)uu(bbb)") != 0)
+ return invalid_arguments_error (message);
dbus_message_iter_init(message, &iter);
- // TODO: verify type signature
dbus_message_iter_get_basic(&iter, &path);
dbus_message_iter_next(&iter);
dbus_message_iter_recurse(&iter, &iter_array);
@@ -1933,22 +1934,7 @@ impl_register_keystroke_listener (DBusConnection *bus,
dbus_message_iter_next(&iter);
dbus_message_iter_get_basic(&iter, &mask);
dbus_message_iter_next(&iter);
- sig = dbus_message_iter_get_signature (&iter);
- if (sig && !strcmp (sig, "u"))
- dbus_message_iter_get_basic(&iter, &type);
- else
- {
- dbus_message_iter_recurse(&iter, &iter_array);
- while (dbus_message_iter_get_arg_type(&iter_array) != DBUS_TYPE_INVALID)
- {
- dbus_uint32_t t;
- dbus_message_iter_get_basic (&iter_array, &t);
- type |= (1 << t);
- dbus_message_iter_next (&iter_array);
- }
- dbus_message_iter_next (&iter_array);
- }
- dbus_free (sig);
+ dbus_message_iter_get_basic(&iter, &type);
dbus_message_iter_next(&iter);
mode = (Accessibility_EventListenerMode *)g_malloc(sizeof(Accessibility_EventListenerMode));
if (mode)
@@ -2132,7 +2118,7 @@ impl_deregister_keystroke_listener (DBusConnection *bus,
DBusMessage *reply = NULL;
dbus_message_iter_init(message, &iter);
- // TODO: verify type signature
+ if (strcmp (dbus_message_get_signature (message), "oa(iisi)uu") != 0)
dbus_message_iter_get_basic(&iter, &path);
dbus_message_iter_next(&iter);
dbus_message_iter_recurse(&iter, &iter_array);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]