From 7738bca124a2d15f14a3b9573ee468c166077a37 Mon Sep 17 00:00:00 2001 From: luoxu Date: Thu, 29 May 2025 17:29:54 +0800 Subject: [PATCH] fix(ble_mesh): fixed proxy server might send segment message with incorrect format --- components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c | 2 +- components/bt/esp_ble_mesh/core/nimble_host/adapter.c | 2 +- components/bt/esp_ble_mesh/core/proxy_server.c | 2 +- components/bt/esp_ble_mesh/core/scan.c | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c index 89dcd9ef90..ae337570a4 100644 --- a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c @@ -667,7 +667,7 @@ int bt_le_ext_adv_start(const uint8_t inst_id, interval >>= 1; interval += (bt_mesh_get_rand() % (interval + 1)); - BT_INFO("%u->%u", param->interval_min, interval); + BT_DBG("%u->%u", param->interval_min, interval); } #endif diff --git a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c index 7fed0d0bdb..b247734575 100644 --- a/components/bt/esp_ble_mesh/core/nimble_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/nimble_host/adapter.c @@ -1223,7 +1223,7 @@ int bt_le_ext_adv_start(const uint8_t inst_id, interval >>= 1; interval += (bt_mesh_get_rand() % (interval + 1)); - BT_INFO("%u->%u", param->interval_min, interval); + BT_DBG("%u->%u", param->interval_min, interval); } #endif diff --git a/components/bt/esp_ble_mesh/core/proxy_server.c b/components/bt/esp_ble_mesh/core/proxy_server.c index 68f2978609..e806915506 100644 --- a/components/bt/esp_ble_mesh/core/proxy_server.c +++ b/components/bt/esp_ble_mesh/core/proxy_server.c @@ -1363,7 +1363,7 @@ int bt_mesh_proxy_server_segment_send(struct bt_mesh_conn *conn, uint8_t type, net_buf_simple_pull(msg, mtu); while (msg->len) { - if (msg->len + 1 < mtu) { + if (msg->len + 1 <= mtu) { net_buf_simple_push_u8(msg, BLE_MESH_PROXY_PDU_HDR(BLE_MESH_PROXY_SAR_LAST, type)); proxy_send(conn, msg->data, msg->len); break; diff --git a/components/bt/esp_ble_mesh/core/scan.c b/components/bt/esp_ble_mesh/core/scan.c index 9bfa15d361..192f63f879 100644 --- a/components/bt/esp_ble_mesh/core/scan.c +++ b/components/bt/esp_ble_mesh/core/scan.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -102,13 +102,14 @@ int bt_mesh_unprov_dev_info_query(uint8_t uuid[16], uint8_t addr[6], { uint8_t idx = 0; uint8_t cnt = 0; + uint8_t pair_num = unprov_dev_info_fifo.pair_num; - if (uuid == NULL || addr == NULL) { + if (uuid == NULL && addr == NULL) { BT_WARN("No available information to query"); return -1; } - while (cnt < unprov_dev_info_fifo.pair_num) { + while (cnt < pair_num) { idx = (cnt + unprov_dev_info_fifo.start_idx) % BLE_MESH_STORE_UNPROV_INFO_MAX_NUM; if (query_type & BLE_MESH_STORE_UNPROV_INFO_QUERY_TYPE_UUID) { if (!memcmp(unprov_dev_info_fifo.info[idx].addr, addr, 6)) { @@ -134,7 +135,7 @@ int bt_mesh_unprov_dev_info_query(uint8_t uuid[16], uint8_t addr[6], cnt++; } - if (cnt == unprov_dev_info_fifo.pair_num) { + if (cnt == pair_num) { return -1; }