mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'bugfix/smp_sec_flags_v5.4' into 'release/v5.4'
fix(bt/bluedroid): fixed several security issues from NVIDIA (v5.4) See merge request espressif/esp-idf!50568
This commit is contained in:
@@ -1407,10 +1407,11 @@ void btc_hh_cb_handler(btc_msg_t *msg)
|
||||
BTA_DmRemoveDevice(p_dev->bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
#endif
|
||||
btc_hh_remove_device(p_dev->bd_addr);
|
||||
} else {
|
||||
p_dev->dev_status = ESP_HIDH_CONN_STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
btc_hh_cb.status = (BTC_HH_STATUS)BTC_HH_DEV_DISCONNECTED;
|
||||
p_dev->dev_status = ESP_HIDH_CONN_STATE_DISCONNECTED;
|
||||
param.close.status = p_data->dev_status.status;
|
||||
} else {
|
||||
BTC_TRACE_ERROR("Error: cannot find device with handle %d", p_data->dev_status.handle);
|
||||
|
||||
@@ -4490,7 +4490,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
||||
(status == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) ||
|
||||
(status == HCI_ERR_REPEATED_ATTEMPTS)))) {
|
||||
p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
|
||||
p_dev_rec->sec_flags &= ~ (BTM_SEC_LE_LINK_KEY_KNOWN << bit_shift);
|
||||
p_dev_rec->sec_flags &= ~((BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED) << bit_shift);
|
||||
|
||||
|
||||
#ifdef BRCM_NOT_4_BTE
|
||||
@@ -5453,9 +5453,11 @@ static BOOLEAN btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
*******************************************************************************/
|
||||
static BOOLEAN btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
{
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING;
|
||||
|
||||
return (btsnd_hcic_auth_request (p_dev_rec->hci_handle));
|
||||
if (btsnd_hcic_auth_request (p_dev_rec->hci_handle)) {
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -6394,9 +6396,10 @@ void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_sta
|
||||
*******************************************************************************/
|
||||
void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
|
||||
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
btm_sec_update_legacy_auth_state(p_acl_cb, BTM_ACL_LEGACY_AUTH_REMOTE);
|
||||
tACL_CONN *p_acl_cb = btm_handle_to_acl(handle);
|
||||
if (p_acl_cb) {
|
||||
btm_sec_update_legacy_auth_state(p_acl_cb, BTM_ACL_LEGACY_AUTH_REMOTE);
|
||||
}
|
||||
}
|
||||
#endif /// (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_log.h"
|
||||
@@ -65,6 +67,19 @@ static int add_report(temp_hid_report_map_t *map, esp_hid_report_item_t *item)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_report_len_bits_to(uint16_t *len_bits, uint16_t size, uint16_t count)
|
||||
{
|
||||
uint32_t add = (uint32_t)size * (uint32_t)count;
|
||||
uint32_t new_len = (uint32_t)(*len_bits) + add;
|
||||
|
||||
if (new_len > UINT16_MAX) {
|
||||
ESP_LOGE(TAG, "report length overflow: %u + %u * %u", *len_bits, size, count);
|
||||
return -1;
|
||||
}
|
||||
*len_bits = (uint16_t)new_len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handle_report(hid_report_params_t *report, bool first)
|
||||
{
|
||||
if (s_temp_hid_report_map == NULL) {
|
||||
@@ -290,15 +305,34 @@ static int handle_cmd(hid_report_cmd_t *cmd)
|
||||
} else if (cmd->cmd == HID_RM_USAGE) {
|
||||
s_report_params.inner_usage = cmd->value;
|
||||
} else if (cmd->cmd == HID_RM_REPORT_SIZE) {
|
||||
s_report_size = cmd->value;
|
||||
if (cmd->value > UINT16_MAX) {
|
||||
ESP_LOGE(TAG, "REPORT_SIZE too large: %" PRIu32, cmd->value);
|
||||
s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||
return -1;
|
||||
}
|
||||
s_report_size = (uint16_t)cmd->value;
|
||||
} else if (cmd->cmd == HID_RM_REPORT_COUNT) {
|
||||
s_report_count = cmd->value;
|
||||
if (cmd->value > UINT16_MAX) {
|
||||
ESP_LOGE(TAG, "REPORT_COUNT too large: %" PRIu32, cmd->value);
|
||||
s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||
return -1;
|
||||
}
|
||||
s_report_count = (uint16_t)cmd->value;
|
||||
} else if (cmd->cmd == HID_RM_INPUT) {
|
||||
s_report_params.input_len += (s_report_size * s_report_count);
|
||||
if (add_report_len_bits_to(&s_report_params.input_len, s_report_size, s_report_count) != 0) {
|
||||
s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||
return -1;
|
||||
}
|
||||
} else if (cmd->cmd == HID_RM_OUTPUT) {
|
||||
s_report_params.output_len += (s_report_size * s_report_count);
|
||||
if (add_report_len_bits_to(&s_report_params.output_len, s_report_size, s_report_count) != 0) {
|
||||
s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||
return -1;
|
||||
}
|
||||
} else if (cmd->cmd == HID_RM_FEATURE) {
|
||||
s_report_params.feature_len += (s_report_size * s_report_count);
|
||||
if (add_report_len_bits_to(&s_report_params.feature_len, s_report_size, s_report_count) != 0) {
|
||||
s_parse_step = PARSE_WAIT_USAGE_PAGE;
|
||||
return -1;
|
||||
}
|
||||
} else if (cmd->cmd == HID_RM_COLLECTION) {
|
||||
s_collection_depth += 1;
|
||||
} else if (cmd->cmd == HID_RM_END_COLLECTION) {
|
||||
|
||||
Reference in New Issue
Block a user