Bluetooth: ATT: Check ATT payload len against MTU

During allocation ATT pdu buffer there's possibility to precheck
whether length of such buffer doesn't exceeds ATT MTU.

Change-Id: I7f729e4d7f7474d7f33e417ea61a00ceeb7426c5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2015-07-09 12:19:35 +02:00 committed by Anas Nashif
commit 9bf8ad20df

View file

@ -1311,6 +1311,12 @@ struct bt_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
{
struct bt_att_hdr *hdr;
struct bt_buf *buf;
struct bt_att *att = conn->att;
if (len + sizeof(op) > att->mtu) {
BT_WARN("ATT MTU exceeded, max %u, wanted %u\n", att->mtu, len);
return NULL;
}
buf = bt_l2cap_create_pdu(conn);
if (!buf) {