mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(ble/bluedroid): validate SMP pair-fail reason and OOB device
This commit is contained in:
@@ -522,8 +522,17 @@ void smp_proc_sec_grant(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void smp_proc_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
{
|
||||
SMP_TRACE_DEBUG("%s", __func__);
|
||||
p_cb->status = *(UINT8 *)p_data;
|
||||
UINT8 reason = *(UINT8 *)p_data;
|
||||
|
||||
SMP_TRACE_DEBUG("%s reason=0x%02x", __func__, reason);
|
||||
/* A peer may send a reserved or out-of-range reason code; normalize it so
|
||||
* upper layers always receive a defined pairing failure status. */
|
||||
if (reason == SMP_SUCCESS || reason > SMP_MAX_FAIL_RSN_PER_SPEC) {
|
||||
SMP_TRACE_WARNING("%s invalid pairing fail reason 0x%02x", __func__, reason);
|
||||
reason = SMP_PAIR_FAIL_UNKNOWN;
|
||||
}
|
||||
p_cb->status = reason;
|
||||
p_cb->failure = reason;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -443,6 +443,17 @@ void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len, UINT8 *p_data
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reject an OOB reply that does not match the device currently pairing. */
|
||||
if (memcmp(bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) != 0) {
|
||||
SMP_TRACE_ERROR("%s() - Wrong BD Addr", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (btm_find_dev(bd_addr) == NULL) {
|
||||
SMP_TRACE_ERROR("%s() - no dev CB", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (res != SMP_SUCCESS || len == 0 || !p_data) {
|
||||
SMP_TRACE_ERROR("%s pairing failed, res=0x%x len=%u p_data=%p",
|
||||
__func__, res, len, p_data);
|
||||
|
||||
Reference in New Issue
Block a user