Skip to content

Commit 2ef9e28

Browse files
ivaniushkovrlubos
authored andcommitted
[nrf fromtree] Bluetooth: fixing UBSAN warnings related to Codec Configuration
During local testing with UBSAN enabled, warning was reported: bluetooth/host/iso.c:237:2: runtime error: null pointer passed as argument 2, which is declared to never be null It turned out that when datapath doesn't contain codec information, cc_len is 0 and cc is NULL In order to avoid UB, now we call memcpy only when cp->codec_config_len > 0 Signed-off-by: Ivan Iushkov <[email protected]> (cherry picked from commit e8d0900) Signed-off-by: Ivan Iushkov <[email protected]>
1 parent 4c9479b commit 2ef9e28

File tree

1 file changed

+4
-3
lines changed
  • subsys/bluetooth/host

1 file changed

+4
-3
lines changed

subsys/bluetooth/host/iso.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ static int hci_le_setup_iso_data_path(const struct bt_conn *iso, uint8_t dir,
233233
cp->codec_id.vs_codec_id = sys_cpu_to_le16(path->vid);
234234
sys_put_le24(path->delay, cp->controller_delay);
235235
cp->codec_config_len = path->cc_len;
236-
cc = net_buf_add(buf, cp->codec_config_len);
237-
memcpy(cc, path->cc, cp->codec_config_len);
238-
236+
cc = net_buf_add(buf, path->cc_len);
237+
if (path->cc_len) {
238+
memcpy(cc, path->cc, path->cc_len);
239+
}
239240
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SETUP_ISO_PATH, buf, &rsp);
240241
if (err) {
241242
return err;

0 commit comments

Comments
 (0)