diff options
author | Martin Xu <martin.xu@intel.com> | 2010-04-27 17:49:12 +0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-05-06 07:34:10 +0200 |
commit | b4edf97ceebc5d6b2c792351180ffb7286f279b3 (patch) | |
tree | 83f0eabc4d23d9994cb33d119bc64deab6ede06a /plugins/bluetooth.c | |
parent | 3ee48bb2abb77664f0a1fa808e9ae8ce0901b881 (diff) | |
download | connman-b4edf97ceebc5d6b2c792351180ffb7286f279b3.tar.gz connman-b4edf97ceebc5d6b2c792351180ffb7286f279b3.tar.bz2 connman-b4edf97ceebc5d6b2c792351180ffb7286f279b3.zip |
Check error before call dbus_message_get_args to acquire arguments
Function dbus_message_get_args just checks the signature which may
happens to be s(string), then it will just return TRUE, and the error
message is treated as return value.
So dbus_set_error_from_message is used to check the error, before
call dbus_message_get_args.
Diffstat (limited to 'plugins/bluetooth.c')
-rw-r--r-- | plugins/bluetooth.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index 1c0fa964..fabc75f7 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -89,6 +89,12 @@ static void connect_reply(DBusPendingCall *call, void *user_data) dbus_error_init(&error); + if (dbus_set_error_from_message(&error, reply) == TRUE) { + connman_error("%s", error.message); + dbus_error_free(&error); + goto done; + } + if (dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, &interface, DBUS_TYPE_INVALID) == FALSE) { @@ -171,6 +177,12 @@ static void disconnect_reply(DBusPendingCall *call, void *user_data) dbus_error_init(&error); + if (dbus_set_error_from_message(&error, reply) == TRUE) { + connman_error("%s", error.message); + dbus_error_free(&error); + goto done; + } + if (dbus_message_get_args(reply, &error, DBUS_TYPE_INVALID) == FALSE) { if (dbus_error_is_set(&error) == TRUE) { connman_error("%s", error.message); @@ -625,6 +637,12 @@ static void list_adapters_reply(DBusPendingCall *call, void *user_data) dbus_error_init(&error); + if (dbus_set_error_from_message(&error, reply) == TRUE) { + connman_error("%s", error.message); + dbus_error_free(&error); + goto done; + } + if (dbus_message_get_args(reply, &error, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &adapters, &num_adapters, @@ -717,14 +735,24 @@ static void bluetooth_remove(struct connman_device *device) static void powered_reply(DBusPendingCall *call, void *user_data) { + DBusError error; DBusMessage *reply; DBG(""); reply = dbus_pending_call_steal_reply(call); - dbus_message_unref(reply); + dbus_error_init(&error); + if (dbus_set_error_from_message(&error, reply) == TRUE) { + connman_error("%s", error.message); + dbus_error_free(&error); + dbus_message_unref(reply); + dbus_pending_call_unref(call); + return; + } + + dbus_message_unref(reply); dbus_pending_call_unref(call); add_adapter(connection, user_data); |