Skip to content

Commit c0b1ed0

Browse files
jerryyang35dkalowsk
authored andcommitted
Bluetooth: RFCOMM: Fix MTU calculation in rfcomm_connected
The MTU calculation in rfcomm_connected() was incorrectly adding the FCS size instead of subtracting it. This could lead to buffer overflows when sending data that exceeds the actual available space. Fix the calculation by properly subtracting both the RFCOMM header size and the FCS size from the L2CAP MTU to get the correct RFCOMM session MTU. Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
1 parent 79204ec commit c0b1ed0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/bluetooth/host/classic/rfcomm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static void rfcomm_connected(struct bt_l2cap_chan *chan)
430430
/* Need to include UIH header and FCS*/
431431
session->mtu = MIN(session->br_chan.rx.mtu,
432432
session->br_chan.tx.mtu) -
433-
BT_RFCOMM_HDR_SIZE + BT_RFCOMM_FCS_SIZE;
433+
BT_RFCOMM_HDR_SIZE - BT_RFCOMM_FCS_SIZE;
434434

435435
if (session->state == BT_RFCOMM_STATE_CONNECTING) {
436436
rfcomm_send_sabm(session, 0);

0 commit comments

Comments
 (0)