From b379d641c4d1862baa47c7d2522773925aa4dd43 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sun, 4 Nov 2018 14:49:18 -0800 Subject: binding: bluetooth: fix interface removal event Don't send adapter name in 'device' parameter on removal of bluetooth interface. Bug-AGL: SPEC-1630 Change-Id: I15cb4dcc791d36beb8e8b41993644cad331d3cae Signed-off-by: Matt Ranostay --- binding/bluetooth-api.h | 5 +++++ binding/bluetooth-util.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/binding/bluetooth-api.h b/binding/bluetooth-api.h index 31a1d76..209f992 100644 --- a/binding/bluetooth-api.h +++ b/binding/bluetooth-api.h @@ -92,6 +92,11 @@ static inline gchar *bluez_return_device(const char *path) if (!basename) return NULL; basename++; + + /* be sure it is a bluez path with device */ + if (strncmp(basename, "dev_", 4)) + return NULL; + /* at least one character */ return *basename ? g_strdup(basename) : NULL; } diff --git a/binding/bluetooth-util.c b/binding/bluetooth-util.c index 4740cda..963af82 100644 --- a/binding/bluetooth-util.c +++ b/binding/bluetooth-util.c @@ -1033,8 +1033,10 @@ void json_process_path(json_object *jresp, const char *path) { g_free(tmp); tmp = bluez_return_device(path); - json_object_object_add(jresp, "device", json_object_new_string(tmp)); - g_free(tmp); + if (tmp) { + json_object_object_add(jresp, "device", json_object_new_string(tmp)); + g_free(tmp); + } } gchar *return_bluez_path(afb_req_t request) { -- cgit 1.2.3-korg