Stricter check of the MTU size in the BTIF L2CAP socket
Test: manual
Bug: 68359837
Change-Id: I0056044388f8886f704a9ff2f30db09b3110d143
diff --git a/btif/src/btif_sock_l2cap.cc b/btif/src/btif_sock_l2cap.cc
index 3ee6e7a..7c466c1 100644
--- a/btif/src/btif_sock_l2cap.cc
+++ b/btif/src/btif_sock_l2cap.cc
@@ -1004,11 +1004,11 @@
ssize_t count;
OSI_NO_INTR(count = recv(fd, get_l2cap_sdu_start_ptr(buffer), size,
MSG_NOSIGNAL | MSG_DONTWAIT | MSG_TRUNC));
- if (count > L2CAP_LE_MAX_MPS) {
+ if (count > sock->mtu) {
/* This can't happen thanks to check in BluetoothSocket.java but leave
* this in case this socket is ever used anywhere else*/
LOG(ERROR) << "recv more than MTU. Data will be lost: " << count;
- count = L2CAP_LE_MAX_MPS;
+ count = sock->mtu;
}
/* When multiple packets smaller than MTU are flushed to the socket, the