From 1c2eb36135d3cd69cb48b767e934e3415028e064 Mon Sep 17 00:00:00 2001 From: linruihao Date: Mon, 13 Jul 2026 16:07:45 +0800 Subject: [PATCH] fix(bt/bluedroid): fix crash during bredr inquiry when zero-addr device is found --- components/bt/host/bluedroid/stack/btm/btm_ble.c | 3 ++- components/bt/host/bluedroid/stack/btm/btm_dev.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 51768b51fc6..91f418bafb9 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -778,7 +778,8 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR memcmp(p_dev_rec->ble.pseudo_addr, remote_bda, BD_ADDR_LEN) == 0) { *p_dev_type = p_dev_rec->device_type; *p_addr_type = p_dev_rec->ble.ble_addr_type; - } else if (memcmp(p_dev_rec->ble.pseudo_addr, remote_bda, BD_ADDR_LEN) == 0) { + } else if (memcmp(p_dev_rec->ble.pseudo_addr, bd_addr_null, BD_ADDR_LEN) != 0 && + memcmp(p_dev_rec->ble.pseudo_addr, remote_bda, BD_ADDR_LEN) == 0) { *p_dev_type = BT_DEVICE_TYPE_BLE; *p_addr_type = p_dev_rec->ble.ble_addr_type; } else { /* matching static address only */ diff --git a/components/bt/host/bluedroid/stack/btm/btm_dev.c b/components/bt/host/bluedroid/stack/btm/btm_dev.c index 6a8c05f6629..39f5e933089 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/host/bluedroid/stack/btm/btm_dev.c @@ -303,7 +303,8 @@ BOOLEAN btm_find_sec_dev_in_list (void *p_node_data, void *context) } #if BLE_INCLUDED == TRUE // If a LE random address is looking for device record - if (!memcmp(p_sec_dev->ble.pseudo_addr, p_context->context.p_bd_addr, BD_ADDR_LEN)) { + if (memcmp(p_sec_dev->ble.pseudo_addr, bd_addr_null, BD_ADDR_LEN) != 0 && + !memcmp(p_sec_dev->ble.pseudo_addr, p_context->context.p_bd_addr, BD_ADDR_LEN)) { ret = FALSE; }