From: Vishwath Mohan Date: Thu, 9 Nov 2017 06:45:47 +0000 (-0800) Subject: Fix BTM callbacks so callee and caller types match X-Git-Tag: android-x86-9.0-r1~175^2~4^2^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=325abcfa4a039aa6cb0c7a350c11daacd3cc9b62;p=android-x86%2Fsystem-bt.git Fix BTM callbacks so callee and caller types match This CL fixes inconsistencies between the actual type of a callback function, and the type assumed at the call site. This respects the intended function signature. For P, we plan to enable control-flow integrity (CFI) across multiple platform components, including BT. This mismatch will break CFI and cause runtime errors when enabled - so this is also a preemptive measure to get BT compatible in preparation. Bug: 30227045 Test: Builds and runs without errors when CFI is enabled. Change-Id: I8970e6866d8b37a9adf5e040db993d30f1b5103a --- diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc index 019998469..7e2f4395b 100644 --- a/bta/dm/bta_dm_act.cc +++ b/bta/dm/bta_dm_act.cc @@ -76,7 +76,7 @@ static uint8_t bta_dm_authentication_complete_cback(const RawAddress& bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); -static void bta_dm_local_name_cback(const RawAddress& bd_addr); +static void bta_dm_local_name_cback(void* p_name); static bool bta_dm_check_av(uint16_t event); static void bta_dm_bl_change_cback(tBTM_BL_EVENT_DATA* p_data); @@ -2759,7 +2759,7 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { * Returns void * ******************************************************************************/ -static void bta_dm_local_name_cback(UNUSED_ATTR const RawAddress& p_name) { +static void bta_dm_local_name_cback(UNUSED_ATTR void* p_name) { tBTA_DM_SEC sec_event; sec_event.enable.status = BTA_SUCCESS; diff --git a/stack/btm/btm_devctl.cc b/stack/btm/btm_devctl.cc index 59f8bd96c..2e425aa8a 100644 --- a/stack/btm/btm_devctl.cc +++ b/stack/btm/btm_devctl.cc @@ -618,7 +618,7 @@ void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len, * ******************************************************************************/ void btm_vsc_complete(uint8_t* p, uint16_t opcode, uint16_t evt_len, - tBTM_CMPL_CB* p_vsc_cplt_cback) { + tBTM_VSC_CMPL_CB* p_vsc_cplt_cback) { tBTM_VSC_CMPL vcs_cplt_params; /* If there was a callback address for vcs complete, call it */ diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h index c825d04d1..d7c9ed23a 100644 --- a/stack/btm/btm_int.h +++ b/stack/btm/btm_int.h @@ -193,7 +193,7 @@ extern void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC* p_dev_rec); /* Vendor Specific Command complete evt handler */ extern void btm_vsc_complete(uint8_t* p, uint16_t cc_opcode, uint16_t evt_len, - tBTM_CMPL_CB* p_vsc_cplt_cback); + tBTM_VSC_CMPL_CB* p_vsc_cplt_cback); extern void btm_inq_db_reset(void); extern void btm_vendor_specific_evt(uint8_t* p, uint8_t evt_len); extern void btm_delete_stored_link_key_complete(uint8_t* p); diff --git a/stack/btu/btu_hcif.cc b/stack/btu/btu_hcif.cc index 80a9dcb49..03e8bf8d7 100644 --- a/stack/btu/btu_hcif.cc +++ b/stack/btu/btu_hcif.cc @@ -1001,7 +1001,7 @@ static void btu_hcif_hdl_command_complete(uint16_t opcode, uint8_t* p, #endif default: if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) - btm_vsc_complete(p, opcode, evt_len, (tBTM_CMPL_CB*)p_cplt_cback); + btm_vsc_complete(p, opcode, evt_len, (tBTM_VSC_CMPL_CB*)p_cplt_cback); break; } } @@ -1174,14 +1174,14 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status, default: if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) btm_vsc_complete(&status, opcode, 1, - (tBTM_CMPL_CB*)p_vsc_status_cback); + (tBTM_VSC_CMPL_CB*)p_vsc_status_cback); break; } } else { if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) btm_vsc_complete(&status, opcode, 1, - (tBTM_CMPL_CB*)p_vsc_status_cback); + (tBTM_VSC_CMPL_CB*)p_vsc_status_cback); } } }