Skip to content

Commit

Permalink
Fix ble_gap_unpair_oldest_peer to prevent writing to invalid memory
Browse files Browse the repository at this point in the history
  • Loading branch information
darshandobariya7 committed Nov 15, 2023
1 parent d84b41e commit 93023be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6201,7 +6201,7 @@ int
ble_gap_unpair_oldest_peer(void)
{
#if NIMBLE_BLE_SM
ble_addr_t oldest_peer_id_addr;
ble_addr_t oldest_peer_id_addr[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
int num_peers;
int rc;

Expand All @@ -6210,7 +6210,7 @@ ble_gap_unpair_oldest_peer(void)
}

rc = ble_store_util_bonded_peers(
&oldest_peer_id_addr, &num_peers, 1);
&oldest_peer_id_addr[0], &num_peers, MYNEWT_VAL(BLE_STORE_MAX_BONDS));
if (rc != 0) {
return rc;
}
Expand All @@ -6219,7 +6219,7 @@ ble_gap_unpair_oldest_peer(void)
return BLE_HS_ENOENT;
}

rc = ble_gap_unpair(&oldest_peer_id_addr);
rc = ble_gap_unpair(&oldest_peer_id_addr[0]);
if (rc != 0) {
return rc;
}
Expand Down

0 comments on commit 93023be

Please sign in to comment.