Skip to content

Commit 598ef74

Browse files
louiscaronAnas Nashif
authored andcommitted
Bluetooth: fix write cmd handling
The data pointer and length was not updated before invoking the write_rsp function therefore providing pointer to the handle. Change-Id: I5c27ab7a793979dffb8f1f2c68def027c45f2376 Signed-off-by: Louis Caron <[email protected]>
1 parent d568a04 commit 598ef74

File tree

1 file changed

+2
-14
lines changed
  • subsys/bluetooth/host

1 file changed

+2
-14
lines changed

subsys/bluetooth/host/att.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,13 +1185,9 @@ static uint8_t att_write_rsp(struct bt_conn *conn, uint8_t op, uint8_t rsp,
11851185
static uint8_t att_write_req(struct bt_att *att, struct net_buf *buf)
11861186
{
11871187
struct bt_conn *conn = att->chan.chan.conn;
1188-
struct bt_att_write_req *req;
11891188
uint16_t handle;
11901189

1191-
req = (void *)buf->data;
1192-
1193-
handle = sys_le16_to_cpu(req->handle);
1194-
net_buf_pull(buf, sizeof(*req));
1190+
handle = net_buf_pull_le16(buf);
11951191

11961192
BT_DBG("handle 0x%04x", handle);
11971193

@@ -1384,17 +1380,9 @@ static uint8_t att_exec_write_req(struct bt_att *att, struct net_buf *buf)
13841380
static uint8_t att_write_cmd(struct bt_att *att, struct net_buf *buf)
13851381
{
13861382
struct bt_conn *conn = att->chan.chan.conn;
1387-
struct bt_att_write_cmd *req;
13881383
uint16_t handle;
13891384

1390-
if (buf->len < sizeof(*req)) {
1391-
/* Commands don't have any response */
1392-
return 0;
1393-
}
1394-
1395-
req = (void *)buf->data;
1396-
1397-
handle = sys_le16_to_cpu(req->handle);
1385+
handle = net_buf_pull_le16(buf);
13981386

13991387
BT_DBG("handle 0x%04x", handle);
14001388

0 commit comments

Comments
 (0)