Skip to content

Commit e586213

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SDP: Fix out of bounds issue
This is a negative detection. The conn index should be never out of bounds of the array `bt_sdp_client_pool`. Because the size of the array is `CONFIG_BT_MAX_CONN`. To improve the readability, add a `__ASSERT` checking here. Check whether the conn index is out of bounds. Fix #99985 Signed-off-by: Lyle Zhu <[email protected]>
1 parent 2b827d3 commit e586213

File tree

1 file changed

+5
-1
lines changed
  • subsys/bluetooth/host/classic

1 file changed

+5
-1
lines changed

subsys/bluetooth/host/classic/sdp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2817,8 +2817,12 @@ static int sdp_client_discovery_start(struct bt_conn *conn,
28172817
{
28182818
int err;
28192819
struct bt_sdp_client *session;
2820+
size_t index;
28202821

2821-
session = &bt_sdp_client_pool[bt_conn_index(conn)];
2822+
index = (size_t)bt_conn_index(conn);
2823+
__ASSERT(index < ARRAY_SIZE(bt_sdp_client_pool), "ACL CONN index is out of bounds");
2824+
2825+
session = &bt_sdp_client_pool[index];
28222826
k_sem_take(&session->sem_lock, K_FOREVER);
28232827
if (session->state == SDP_CLIENT_CONNECTING ||
28242828
session->state == SDP_CLIENT_CONNECTED) {

0 commit comments

Comments
 (0)