Skip to content
Permalink
Browse files

Bluetooth: GATT: Fix iterating over requested handle range

If handle is over the range end return since handles are always placed
in ascending order.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information...
Vudentz authored and jhedberg committed Apr 8, 2019
1 parent 4154f27 commit 755a6e503e09bfd035b7d3f6bc67b1f2523ac60a
Showing with 6 additions and 2 deletions.
  1. +6 −2 subsys/bluetooth/host/gatt.c
@@ -946,9 +946,13 @@ void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle,
for (i = 0; i < svc->attr_count; i++) {
struct bt_gatt_attr *attr = &svc->attrs[i];

/* Stop if over the requested range */
if (attr->handle > end_handle) {
return;
}

/* Check if attribute handle is within range */
if (attr->handle < start_handle ||
attr->handle > end_handle) {
if (attr->handle < start_handle) {
continue;
}

0 comments on commit 755a6e5

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