Skip to content

Commit 549bc7a

Browse files
committed
Bluetooth: CAP: Add ep conn check in unicast audio start
Add check in valid_unicast_audio_start_param to verify that the ep connection matches the member_conn. Signed-off-by: Emil Gydesen <[email protected]>
1 parent ad34ce1 commit 549bc7a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

subsys/bluetooth/audio/cap_initiator.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,11 @@ bool bt_cap_initiator_valid_unicast_audio_start_param(
11581158
const union bt_cap_set_member *member = &stream_param->member;
11591159
const struct bt_cap_stream *cap_stream = stream_param->stream;
11601160
const struct bt_audio_codec_cfg *codec_cfg = stream_param->codec_cfg;
1161+
const struct bt_bap_ep *ep = stream_param->ep;
11611162
const struct bt_bap_stream *bap_stream;
11621163
const struct bt_conn *member_conn =
11631164
bt_cap_common_get_member_conn(param->type, member);
1165+
struct bt_conn *ep_conn;
11641166

11651167
if (member == NULL) {
11661168
LOG_DBG("param->members[%zu] is NULL", i);
@@ -1182,11 +1184,26 @@ bool bt_cap_initiator_valid_unicast_audio_start_param(
11821184
return false;
11831185
}
11841186

1185-
CHECKIF(stream_param->ep == NULL) {
1187+
if (ep == NULL) {
11861188
LOG_DBG("param->stream_params[%zu].ep is NULL", i);
11871189
return false;
11881190
}
11891191

1192+
ep_conn = bt_bap_ep_get_conn(ep);
1193+
if (ep_conn == NULL) {
1194+
LOG_DBG("param->stream_params[%zu].ep is invalid", i);
1195+
return false;
1196+
}
1197+
if (ep_conn != member_conn) {
1198+
LOG_DBG("param->stream_params[%zu].ep conn %p does not match "
1199+
"param->members[%zu] %p",
1200+
i, ep_conn, i, member_conn);
1201+
bt_conn_unref(ep_conn);
1202+
1203+
return false;
1204+
}
1205+
bt_conn_unref(ep_conn);
1206+
11901207
CHECKIF(member == NULL) {
11911208
LOG_DBG("param->stream_params[%zu].member is NULL", i);
11921209
return false;

0 commit comments

Comments
 (0)