Răsfoiți Sursa

Merge branch 'bugfix/fix_gattc_disc_char_by_uuid_panic' into 'master'

Bluedroid: correct the length of att read by type pdu

Closes BT-2874

See merge request espressif/esp-idf!20686
Wang Meng Yang 3 ani în urmă
părinte
comite
2cbc83a4c7
1 a modificat fișierele cu 3 adăugiri și 1 ștergeri
  1. 3 1
      components/bt/host/bluedroid/stack/gatt/att_protocol.c

+ 3 - 1
components/bt/host/bluedroid/stack/gatt/att_protocol.c

@@ -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;