Skip to content

Commit

Permalink
bluedroid: correct the length of att read by type pdu
Browse files Browse the repository at this point in the history
  • Loading branch information
esp-cjh committed Dec 19, 2022
1 parent dfa9a81 commit 4b7702c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/bt/host/bluedroid/stack/gatt/att_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ BT_HDR *attp_build_browse_cmd(UINT8 op_code, UINT16 s_hdl, UINT16 e_hdl, tBT_UUI
{
BT_HDR *p_buf = NULL;
UINT8 *p;
/* length of ATT_READ_BY_TYPE_REQ PDU: opcode(1) + start_handle (2) + end_handle (2) + uuid (2 or 16) */
const UINT8 payload_size = 1 + 2 + 2 + ((uuid.len == LEN_UUID_16) ? LEN_UUID_16 : LEN_UUID_128);

if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR) + 8 + L2CAP_MIN_OFFSET)) != NULL) {
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET)) != NULL) {
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
/* Describe the built message location and size */
p_buf->offset = L2CAP_MIN_OFFSET;
Expand Down

0 comments on commit 4b7702c

Please sign in to comment.