From 747daffc28db4aafd51eba352eb0dfe03594ad92 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Sat, 6 May 2023 14:26:16 +0800 Subject: [PATCH] bluedroid: fix ble adv data construct for device name --- components/bt/host/bluedroid/stack/btm/btm_ble_gap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 20fa7e5330..8ade03bf49 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -2169,9 +2169,10 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst, #if BTM_MAX_LOC_BD_NAME_LEN > 0 if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) { if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) { - *p++ = len - MIN_ADV_LENGTH + 1; + cp_len = (UINT16)(len - MIN_ADV_LENGTH); + *p++ = cp_len + 1; *p++ = BTM_BLE_AD_TYPE_NAME_SHORT; - ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, len - MIN_ADV_LENGTH); + ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len); } else { cp_len = (UINT16)strlen(btm_cb.cfg.bd_name); *p++ = cp_len + 1;