Skip to content

Commit 05e64bd

Browse files
jerryyang35dkalowsk
authored andcommitted
Bluetooth: L2CAP: Limit BR/EDR L2CAP RX MTU to configured value
Ensure that the BR/EDR L2CAP RX MTU is limited to the configured BT_L2CAP_RX_MTU value during channel configuration. This change prevent potential buffer overflow issues when receiving data larger than the configured buffer size. Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
1 parent c0b1ed0 commit 05e64bd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

subsys/bluetooth/host/classic/l2cap_br.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4664,11 +4664,16 @@ int bt_l2cap_br_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan, u
46644664
return -EBUSY;
46654665
}
46664666

4667+
if (!br_chan->rx.mtu) {
4668+
br_chan->rx.mtu = BT_L2CAP_RX_MTU;
4669+
}
46674670
#if defined(CONFIG_BT_L2CAP_RET_FC)
46684671
err = l2cap_br_check_chan_config(conn, br_chan);
46694672
if (err) {
46704673
return err;
46714674
}
4675+
#else
4676+
br_chan->rx.mtu = MIN(br_chan->rx.mtu, BT_L2CAP_RX_MTU);
46724677
#endif /* CONFIG_BT_L2CAP_RET_FC */
46734678

46744679
if (!l2cap_br_chan_add(conn, chan, l2cap_br_chan_destroy)) {

0 commit comments

Comments
 (0)