Skip to content

Commit 1980d38

Browse files
lylezhu2012m-alperen-sener
authored andcommitted
[nrf fromtree] Bluetooth: SDP: Check if frame len is consistent with attr list count
The total attributes list bytes count is only used to check the tail room of response buffer. And the remaining frame length is used to copy data from receiving buffer. It does not check whether the remaining frame length is consistent with the total attributes list bytes count. Add the checking to make sure the attributes list is complete. And it is used to make sure the response buffer can be accessed safety. Signed-off-by: Lyle Zhu <[email protected]> (cherry picked from commit 50a3a6e)
1 parent 86176f0 commit 1980d38

File tree

1 file changed

+5
-1
lines changed
  • subsys/bluetooth/host/classic

1 file changed

+5
-1
lines changed

subsys/bluetooth/host/classic/sdp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,8 +2053,12 @@ static int sdp_client_receive_ssa_sa(struct bt_sdp_client *session, struct net_b
20532053

20542054
/* Get total value of all attributes to be collected */
20552055
frame_len -= sdp_client_get_total(session, buf, &total);
2056+
if (frame_len != total) {
2057+
LOG_ERR("Invalid attribute lists");
2058+
return 0;
2059+
}
20562060

2057-
if (total > net_buf_tailroom(session->rec_buf)) {
2061+
if (frame_len > net_buf_tailroom(session->rec_buf)) {
20582062
LOG_WRN("Not enough room for getting records data");
20592063
goto iterate;
20602064
}

0 commit comments

Comments
 (0)