aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'attrib/client.c')
-rw-r--r--attrib/client.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/attrib/client.c b/attrib/client.c
index 9aa8b808..6fb55557 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -172,7 +172,7 @@ static int gatt_path_cmp(gconstpointer a, gconstpointer b)
return strcmp(gatt->path, path);
}
-static int characteristic_cmp(gconstpointer a, gconstpointer b)
+static int characteristic_handle_cmp(gconstpointer a, gconstpointer b)
{
const struct characteristic *chr = a;
uint16_t handle = GPOINTER_TO_UINT(b);
@@ -180,6 +180,14 @@ static int characteristic_cmp(gconstpointer a, gconstpointer b)
return chr->handle - handle;
}
+static int characteristic_path_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct characteristic *chr = a;
+ const char *path = b;
+
+ return g_strcmp0(chr->path, path);
+}
+
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
{
DBusMessageIter dict;
@@ -273,7 +281,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len,
prim = lprim->data;
lchr = g_slist_find_custom(prim->chars,
- GUINT_TO_POINTER(handle), characteristic_cmp);
+ GUINT_TO_POINTER(handle), characteristic_handle_cmp);
if (lchr) {
chr = lchr->data;
break;
@@ -407,6 +415,10 @@ static DBusMessage *register_watcher(DBusConnection *conn,
DBUS_TYPE_INVALID))
return NULL;
+ if (!g_slist_find_custom(prim->chars, path, characteristic_path_cmp))
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
+ "Invalid path");
+
/*
* FIXME: If the service doesn't support Client Characteristic
* Configuration it is necessary to poll the server from time