mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(nimble): Added security related fixes
This commit is contained in:
committed by
Rahul Tank
parent
b6aaa5f765
commit
f2b7aa1db8
Submodule components/bt/host/nimble/nimble updated: 655895824d...843673ada2
@@ -133,13 +133,19 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
||||
adv_config_done |= scan_rsp_config_flag;
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT:
|
||||
g_ble_cfg_p->read_fn(event, gatts_if, param);
|
||||
if (g_ble_cfg_p && g_ble_cfg_p->read_fn) {
|
||||
g_ble_cfg_p->read_fn(event, gatts_if, param);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
g_ble_cfg_p->write_fn(event, gatts_if, param);
|
||||
if (g_ble_cfg_p && g_ble_cfg_p->write_fn) {
|
||||
g_ble_cfg_p->write_fn(event, gatts_if, param);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_EXEC_WRITE_EVT:
|
||||
g_ble_cfg_p->exec_write_fn(event, gatts_if, param);
|
||||
if (g_ble_cfg_p && g_ble_cfg_p->exec_write_fn) {
|
||||
g_ble_cfg_p->exec_write_fn(event, gatts_if, param);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_MTU_EVT:
|
||||
ESP_LOGD(TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu);
|
||||
@@ -155,7 +161,9 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
ESP_LOGD(TAG, "ESP_GATTS_CONNECT_EVT, conn_id = %d", param->connect.conn_id);
|
||||
g_ble_cfg_p->connect_fn(event, gatts_if, param);
|
||||
if (g_ble_cfg_p && g_ble_cfg_p->connect_fn) {
|
||||
g_ble_cfg_p->connect_fn(event, gatts_if, param);
|
||||
}
|
||||
esp_ble_conn_update_params_t conn_params = {0};
|
||||
memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
|
||||
memcpy(s_cached_remote_bda, param->connect.remote_bda, sizeof(esp_bd_addr_t));
|
||||
@@ -168,7 +176,9 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
||||
break;
|
||||
case ESP_GATTS_DISCONNECT_EVT:
|
||||
ESP_LOGD(TAG, "ESP_GATTS_DISCONNECT_EVT, reason = %d", param->disconnect.reason);
|
||||
g_ble_cfg_p->disconnect_fn(event, gatts_if, param);
|
||||
if (g_ble_cfg_p && g_ble_cfg_p->disconnect_fn) {
|
||||
g_ble_cfg_p->disconnect_fn(event, gatts_if, param);
|
||||
}
|
||||
memset(s_cached_remote_bda, 0, sizeof(esp_bd_addr_t));
|
||||
esp_ble_gap_start_advertising(&g_ble_cfg_p->adv_params);
|
||||
break;
|
||||
@@ -217,10 +227,12 @@ simple_ble_cfg_t *simple_ble_init(void)
|
||||
|
||||
esp_err_t simple_ble_deinit(void)
|
||||
{
|
||||
free(g_ble_cfg_p->gatt_db);
|
||||
g_ble_cfg_p->gatt_db = NULL;
|
||||
free(g_ble_cfg_p);
|
||||
simple_ble_cfg_t *ble_cfg = g_ble_cfg_p;
|
||||
g_ble_cfg_p = NULL;
|
||||
if (ble_cfg) {
|
||||
ble_cfg->gatt_db = NULL;
|
||||
free(ble_cfg);
|
||||
}
|
||||
|
||||
free(g_gatt_table_map);
|
||||
g_gatt_table_map = NULL;
|
||||
|
||||
@@ -71,6 +71,7 @@ typedef struct _protocomm_ble {
|
||||
} _protocomm_ble_internal_t;
|
||||
|
||||
static _protocomm_ble_internal_t *protoble_internal;
|
||||
static esp_gatts_attr_db_t *s_gatt_db;
|
||||
|
||||
static bool protocomm_ble_transport_active(void)
|
||||
{
|
||||
@@ -567,6 +568,8 @@ static ssize_t populate_gatt_db(esp_gatts_attr_db_t **gatt_db_generated)
|
||||
static void protocomm_ble_cleanup(void)
|
||||
{
|
||||
protocomm_ble_reset_prepare_write();
|
||||
free(s_gatt_db);
|
||||
s_gatt_db = NULL;
|
||||
if (protoble_internal) {
|
||||
if (protoble_internal->g_nu_lookup) {
|
||||
for (unsigned i = 0; i < protoble_internal->g_nu_lookup_count; i++) {
|
||||
@@ -686,6 +689,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
||||
|
||||
ble_config->device_name = protocomm_ble_device_name;
|
||||
ble_config->gatt_db_count = populate_gatt_db(&ble_config->gatt_db);
|
||||
s_gatt_db = ble_config->gatt_db;
|
||||
|
||||
ble_config->ble_bonding = config->ble_bonding;
|
||||
ble_config->ble_sm_sc = config->ble_sm_sc;
|
||||
@@ -699,7 +703,10 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con
|
||||
|
||||
if (ble_config->gatt_db_count == -1) {
|
||||
ESP_LOGE(TAG, "Invalid GATT database count");
|
||||
simple_ble_deinit();
|
||||
free(s_gatt_db);
|
||||
s_gatt_db = NULL;
|
||||
ble_config->gatt_db = NULL;
|
||||
free(ble_config);
|
||||
protocomm_ble_cleanup();
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user