aboutsummaryrefslogtreecommitdiffstats
path: root/attrib
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-08-25 09:41:53 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-09-22 22:34:26 +0300
commit8125506bc14c1b2e50dfa28a3f893ff25d671a82 (patch)
tree5c1453260890abb924f848e3408ae68d9306dccb /attrib
parent316f35e7d879a64195e1464cf55b95e3cbe6a576 (diff)
downloadbluez-8125506bc14c1b2e50dfa28a3f893ff25d671a82.tar.gz
bluez-8125506bc14c1b2e50dfa28a3f893ff25d671a82.tar.xz
bluez-8125506bc14c1b2e50dfa28a3f893ff25d671a82.zip
Return an error if the path doesn't exist when registering a watcher
In the register characteristic watcher method, the given parameter (characteristic path) shall be validated before register the watcher.
Diffstat (limited to 'attrib')
-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