summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-06-02 14:57:57 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-06-02 14:57:57 +0000
commit798f888e7b2b0c94705bd1aea9a81934a1331d03 (patch)
tree132d6387bbb930bdb37838048d158a957816343c
parent5093d69a31cfc7e27235c7e9d6481c82e3867891 (diff)
RemoveBonding: return DoesNotExist when the link key is not found
-rw-r--r--hcid/dbus-adapter.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 86a43c81..1d1b7762 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -1783,7 +1783,7 @@ static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBu
DBusMessage *signal;
DBusError err;
char filename[PATH_MAX + 1];
- char *addr_ptr;
+ char *addr_ptr, *str;
bdaddr_t bdaddr;
int dd;
@@ -1807,12 +1807,21 @@ static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBu
snprintf(filename, PATH_MAX, "%s/%s/linkkeys", STORAGEDIR, dbus_data->address);
- /* Delete the link key from storage */
- if (textfile_del(filename, addr_ptr)) {
+ /* textfile_del doesn't return an error when the key is not found */
+ str = textfile_get(filename, addr_ptr);
+ if (!str) {
hci_close_dev(dd);
return error_bonding_does_not_exist(conn, msg);
}
+ free(str);
+
+ /* Delete the link key from storage */
+ if (textfile_del(filename, addr_ptr) < 0) {
+ hci_close_dev(dd);
+ return error_failed(conn, msg, errno);
+ }
+
str2ba(addr_ptr, &bdaddr);
/* Delete the link key from the Bluetooth chip */