Skip to content

Commit

Permalink
fix(ble/bluedroid): Prevent esp_ble_gatts_send_indicate() with value_…
Browse files Browse the repository at this point in the history
…len > 512
  • Loading branch information
nebkat committed Dec 4, 2024
1 parent 030c995 commit 0eb0a09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion components/bt/host/bluedroid/api/esp_gatts_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,
uint16_t value_len, uint8_t *value, bool need_confirm)
{
if (value_len > ESP_GATT_MAX_ATTR_LEN) {
LOG_ERROR("%s, value_len > ESP_GATT_MAX_ATTR_LEN.", __func__);
return ESP_ERR_INVALID_SIZE;
}

btc_msg_t msg = {0};
btc_ble_gatts_args_t arg;

Expand All @@ -272,7 +277,7 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
}

if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap channel is congest.", __func__);
return ESP_FAIL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
/**
* @brief Send indicate or notify to GATT client.
* Set param need_confirm as false will send notification, otherwise indication.
* Note: the size of indicate or notify data need less than MTU size,see "esp_ble_gattc_send_mtu_req".
* Note: value_len must be less than min(512, MTU - 3), see "esp_ble_gattc_send_mtu_req".
*
* @param[in] gatts_if: GATT server access interface
* @param[in] conn_id - connection id to indicate.
Expand Down

0 comments on commit 0eb0a09

Please sign in to comment.