Skip to content

Commit 7948c30

Browse files
committed
Bluetooth: Host: L2CAP: Fix checking signaling packets size
Recent test specification added additional test for validating invalid packet sizes on L2CAP signaling channel. IUT is allowed to either disconnect link, ignore packet, reject packet or issue a warning to upper tester if other action is taken. To keep things in line with previous check for too small size simply ignore fixed size packets of invalid length. This was affecting L2CAP/COS/CED/BI-11-C qualification test. Signed-off-by: Szymon Janc <[email protected]>
1 parent 6e34acc commit 7948c30

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

subsys/bluetooth/host/l2cap.c

+24-16
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,9 @@ static void le_conn_param_rsp(struct bt_l2cap *l2cap, struct net_buf *buf)
10491049
{
10501050
struct bt_l2cap_conn_param_rsp *rsp = (void *)buf->data;
10511051

1052-
if (buf->len < sizeof(*rsp)) {
1053-
LOG_ERR("Too small LE conn param rsp");
1052+
if (buf->len != sizeof(*rsp)) {
1053+
LOG_ERR("Invalid LE conn param rsp size (%u != %zu)",
1054+
buf->len, sizeof(*rsp));
10541055
return;
10551056
}
10561057

@@ -1066,8 +1067,9 @@ static void le_conn_param_update_req(struct bt_l2cap *l2cap, uint8_t ident,
10661067
struct bt_l2cap_conn_param_req *req = (void *)buf->data;
10671068
bool accepted;
10681069

1069-
if (buf->len < sizeof(*req)) {
1070-
LOG_ERR("Too small LE conn update param req");
1070+
if (buf->len != sizeof(*req)) {
1071+
LOG_ERR("Invalid LE conn update param req size (%u != %zu)",
1072+
buf->len, sizeof(*req));
10711073
return;
10721074
}
10731075

@@ -1458,8 +1460,9 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
14581460
uint16_t psm, scid, mtu, mps, credits;
14591461
uint16_t result;
14601462

1461-
if (buf->len < sizeof(*req)) {
1462-
LOG_ERR("Too small LE conn req packet size");
1463+
if (buf->len != sizeof(*req)) {
1464+
LOG_ERR("Invalid LE conn req packet size (%u != %zu)",
1465+
buf->len, sizeof(*req));
14631466
return;
14641467
}
14651468

@@ -1759,8 +1762,9 @@ static void le_ecred_reconf_rsp(struct bt_l2cap *l2cap, uint8_t ident,
17591762
struct bt_l2cap_le_chan *ch;
17601763
uint16_t result;
17611764

1762-
if (buf->len < sizeof(*rsp)) {
1763-
LOG_ERR("Too small ecred reconf rsp packet size");
1765+
if (buf->len != sizeof(*rsp)) {
1766+
LOG_ERR("Invalid ecred reconf rsp packet size (%u != %zu)",
1767+
buf->len, sizeof(*rsp));
17641768
return;
17651769
}
17661770

@@ -1820,8 +1824,9 @@ static void le_disconn_req(struct bt_l2cap *l2cap, uint8_t ident,
18201824
struct bt_l2cap_disconn_rsp *rsp;
18211825
uint16_t dcid;
18221826

1823-
if (buf->len < sizeof(*req)) {
1824-
LOG_ERR("Too small LE conn req packet size");
1827+
if (buf->len != sizeof(*req)) {
1828+
LOG_ERR("Invalid LE conn req packet size (%u != %zu)",
1829+
buf->len, sizeof(*req));
18251830
return;
18261831
}
18271832

@@ -2039,8 +2044,9 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident,
20392044
struct bt_l2cap_le_conn_rsp *rsp = (void *)buf->data;
20402045
uint16_t dcid, mtu, mps, credits, result;
20412046

2042-
if (buf->len < sizeof(*rsp)) {
2043-
LOG_ERR("Too small LE conn rsp packet size");
2047+
if (buf->len != sizeof(*rsp)) {
2048+
LOG_ERR("Invalid LE conn rsp packet size (%u != %zu)",
2049+
buf->len, sizeof(*rsp));
20442050
return;
20452051
}
20462052

@@ -2111,8 +2117,9 @@ static void le_disconn_rsp(struct bt_l2cap *l2cap, uint8_t ident,
21112117
struct bt_l2cap_disconn_rsp *rsp = (void *)buf->data;
21122118
uint16_t scid;
21132119

2114-
if (buf->len < sizeof(*rsp)) {
2115-
LOG_ERR("Too small LE disconn rsp packet size");
2120+
if (buf->len != sizeof(*rsp)) {
2121+
LOG_ERR("Invalid LE disconn rsp packet size (%u != %zu)",
2122+
buf->len, sizeof(*rsp));
21162123
return;
21172124
}
21182125

@@ -2137,8 +2144,9 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident,
21372144
struct bt_l2cap_le_chan *le_chan;
21382145
uint16_t credits, cid;
21392146

2140-
if (buf->len < sizeof(*ev)) {
2141-
LOG_ERR("Too small LE Credits packet size");
2147+
if (buf->len != sizeof(*ev)) {
2148+
LOG_ERR("Invalid LE Credits packet size (%u != %zu)",
2149+
buf->len, sizeof(*ev));
21422150
return;
21432151
}
21442152

0 commit comments

Comments
 (0)