Skip to content

Commit

Permalink
nimble/host: Validate advertising instance before parsing event
Browse files Browse the repository at this point in the history
Advertising instance is used for indexing slave state array. Since
instance is provided by host invalid handle in event means there is
bug in controller.
  • Loading branch information
sjanc committed Sep 24, 2024
1 parent 845ea65 commit f393308
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nimble/host/src/ble_hs_hci_evt.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ ble_hs_hci_evt_le_adv_set_terminated(uint8_t subevent, const void *data,
return BLE_HS_ECONTROLLER;
}

/* this indicates bug in controller as host uses instances from
* 0-BLE_ADV_INSTANCES range only
*/
if (ev->adv_handle >= BLE_ADV_INSTANCES) {
return BLE_HS_ECONTROLLER;
}

if (ev->status == 0) {
/* ignore return code as we need to terminate advertising set anyway */
ble_gap_rx_conn_complete(&pend_conn_complete, ev->adv_handle);
Expand All @@ -900,6 +907,13 @@ ble_hs_hci_evt_le_scan_req_rcvd(uint8_t subevent, const void *data,
return BLE_HS_ECONTROLLER;
}

/* this indicates bug in controller as host uses instances from
* 0-BLE_ADV_INSTANCES range only
*/
if (ev->adv_handle >= BLE_ADV_INSTANCES) {
return BLE_HS_ECONTROLLER;
}

ble_gap_rx_scan_req_rcvd(ev);
#endif

Expand Down

0 comments on commit f393308

Please sign in to comment.