From 9d4cf4d70ca4f644d390b1c5b584865595884c89 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 7bc86d38e70..caee8fd2657 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -663,7 +663,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 47a5da7f2d1..d5e14cc0043 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; }