Skip to content
Permalink
Browse files

Bluetooth: host: Fix gatt indicate when conn is NULL

Fix gatt indicate when conn is NULL and called with characteristic
declaration as the attribute argument. In this case the handle was not
advanced to the characteristic value. This is inconsistent with the rest
of the notify and indicate API

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
  • Loading branch information...
joerchan authored and jhedberg committed Jun 5, 2019
1 parent 82497ec commit e182d75ef7b4030a02e62bf483c33e58dbcce006
Showing with 11 additions and 11 deletions.
  1. +11 −11 subsys/bluetooth/host/gatt.c
@@ -1388,17 +1388,6 @@ static int gatt_indicate(struct bt_conn *conn, u16_t handle,
}
#endif

/* Check if attribute is a characteristic then adjust the handle */
if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) {
struct bt_gatt_chrc *chrc = params->attr->user_data;

if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) {
return -EINVAL;
}

handle++;
}

buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE,
sizeof(*ind) + params->len);
if (!buf) {
@@ -1615,6 +1604,17 @@ int bt_gatt_indicate(struct bt_conn *conn,
return -ENOENT;
}

/* Check if attribute is a characteristic then adjust the handle */
if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) {
struct bt_gatt_chrc *chrc = params->attr->user_data;

if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) {
return -EINVAL;
}

handle++;
}

if (conn) {
return gatt_indicate(conn, handle, params);
}

0 comments on commit e182d75

Please sign in to comment.
You can’t perform that action at this time.