From 02789d311405fe2c3770106a99d7441551577017 Mon Sep 17 00:00:00 2001 From: weitianhua Date: Sat, 14 Mar 2020 14:52:01 +0800 Subject: [PATCH 1/2] Initialize mem_start and mem_end --- components/bt/bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/bt.c b/components/bt/bt.c index 3da6f8f70c..d4550b806f 100644 --- a/components/bt/bt.c +++ b/components/bt/bt.c @@ -817,7 +817,7 @@ static void btdm_controller_mem_init(void) esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode) { bool update = true; - intptr_t mem_start, mem_end; + intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL; if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { return ESP_ERR_INVALID_STATE; From 737dd8b2f19dd1214f1754275756d20107f3efa9 Mon Sep 17 00:00:00 2001 From: weitianhua Date: Sat, 14 Mar 2020 15:00:31 +0800 Subject: [PATCH 2/2] Remove (x2) varible for BCM_STRNCPY_S and BCM_STRCPY_S --- components/bt/bluedroid/bta/av/bta_av_api.c | 2 +- components/bt/bluedroid/bta/av/bta_av_main.c | 5 +- components/bt/bluedroid/bta/dm/bta_dm_act.c | 48 ++++++++----------- components/bt/bluedroid/bta/dm/bta_dm_api.c | 2 +- .../bta/hf_client/bta_hf_client_api.c | 2 +- components/bt/bluedroid/stack/avdt/avdt_api.c | 2 +- components/bt/bluedroid/stack/btm/btm_ble.c | 3 +- components/bt/bluedroid/stack/btm/btm_dev.c | 3 +- .../bt/bluedroid/stack/btm/btm_devctl.c | 2 +- components/bt/bluedroid/stack/btm/btm_sec.c | 10 ++-- .../bt/bluedroid/stack/gatt/gatt_utils.c | 2 +- .../bluedroid/stack/include/stack/bt_types.h | 4 +- 12 files changed, 36 insertions(+), 49 deletions(-) diff --git a/components/bt/bluedroid/bta/av/bta_av_api.c b/components/bt/bluedroid/bta/av/bta_av_api.c index a0daa89f15..dc1dea2201 100644 --- a/components/bt/bluedroid/bta/av/bta_av_api.c +++ b/components/bt/bluedroid/bta/av/bta_av_api.c @@ -114,7 +114,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, p_buf->hdr.layer_specific = chnl; p_buf->hdr.event = BTA_AV_API_REGISTER_EVT; if (p_service_name) { - BCM_STRNCPY_S(p_buf->p_service_name, sizeof(p_buf->p_service_name), p_service_name, BTA_SERVICE_NAME_LEN); + BCM_STRNCPY_S(p_buf->p_service_name, p_service_name, BTA_SERVICE_NAME_LEN); p_buf->p_service_name[BTA_SERVICE_NAME_LEN - 1] = 0; } else { p_buf->p_service_name[0] = 0; diff --git a/components/bt/bluedroid/bta/av/bta_av_main.c b/components/bt/bluedroid/bta/av/bta_av_main.c index ad3a54c28f..f019b13c7e 100644 --- a/components/bt/bluedroid/bta/av/bta_av_main.c +++ b/components/bt/bluedroid/bta/av/bta_av_main.c @@ -483,8 +483,7 @@ static void bta_av_api_sink_enable(tBTA_AV_DATA *p_data) activate_sink = p_data->hdr.layer_specific; APPL_TRACE_DEBUG("bta_av_api_sink_enable %d \n", activate_sink) char p_service_name[BTA_SERVICE_NAME_LEN + 1]; - BCM_STRNCPY_S(p_service_name, sizeof(p_service_name), - BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN); + BCM_STRNCPY_S(p_service_name, BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN); if (activate_sink) { AVDT_SINK_Activate(); @@ -526,7 +525,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) tBTA_UTL_COD cod; UINT8 index = 0; char p_avk_service_name[BTA_SERVICE_NAME_LEN + 1]; - BCM_STRNCPY_S(p_avk_service_name, sizeof(p_avk_service_name), BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN); + BCM_STRNCPY_S(p_avk_service_name, BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN); memset(&cs, 0, sizeof(tAVDT_CS)); diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index d5149f3c93..05d5e6ef2d 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -1645,7 +1645,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) if (SDP_FindServiceUUIDInRec(p_sdp_rec, &service_uuid)) { /* send result back to app now, one by one */ bdcpy (result.disc_ble_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN)); result.disc_ble_res.bd_name[BD_NAME_LEN] = 0; result.disc_ble_res.service.len = service_uuid.len; result.disc_ble_res.service.uu.uuid16 = service_uuid.uu.uuid16; @@ -1786,8 +1786,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) } bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME), - bta_dm_get_remname(), (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1)); /* make sure the string is null terminated */ p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0; @@ -1813,8 +1812,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data) p_msg->disc_result.result.disc_res.result = BTA_FAILURE; p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found; bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME), - bta_dm_get_remname(), (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1)); /* make sure the string is null terminated */ p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0; @@ -2198,8 +2196,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr) p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT; p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found; bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME), - bta_dm_get_remname(), (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1)); /* make sure the string is terminated */ p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0; @@ -2384,8 +2381,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr) p_msg->disc_result.result.disc_res.result = BTA_SUCCESS; p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found; bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME), - (char *)bta_dm_search_cb.peer_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, (char *)bta_dm_search_cb.peer_name, (BD_NAME_LEN - 1)); /* make sure the string is terminated */ p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0; @@ -2529,7 +2525,7 @@ static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc, rem_name.length = (BD_NAME_LEN - 1); rem_name.remote_bd_name[(BD_NAME_LEN - 1)] = 0; } - BCM_STRNCPY_S((char *)rem_name.remote_bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)rem_name.remote_bd_name, (char *)bd_name, (BD_NAME_LEN - 1)); rem_name.status = BTM_SUCCESS; bta_dm_remname_cback(&rem_name); @@ -2572,7 +2568,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name) /* remote name discovery is done but it could be failed */ bta_dm_search_cb.name_discover_done = TRUE; - BCM_STRNCPY_S((char *)bta_dm_search_cb.peer_name, sizeof(BD_NAME), (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)bta_dm_search_cb.peer_name,(char *)p_remote_name->remote_bd_name, (BD_NAME_LEN)); bta_dm_search_cb.peer_name[BD_NAME_LEN] = 0; BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback); @@ -2585,7 +2581,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name) if ((p_msg = (tBTA_DM_REM_NAME *) osi_malloc(sizeof(tBTA_DM_REM_NAME))) != NULL) { bdcpy (p_msg->result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->result.disc_res.bd_name, sizeof(BD_NAME), (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)p_msg->result.disc_res.bd_name, (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN)); /* make sure the string is null terminated */ p_msg->result.disc_res.bd_name[BD_NAME_LEN] = 0; @@ -2617,7 +2613,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA bdcpy(sec_event.authorize.bd_addr, bd_addr); memcpy(sec_event.authorize.dev_class, dev_class, DEV_CLASS_LEN); - BCM_STRNCPY_S((char *)sec_event.authorize.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)sec_event.authorize.bd_name, (char *)bd_name, (BD_NAME_LEN - 1)); /* make sure the string is null terminated */ sec_event.authorize.bd_name[BD_NAME_LEN - 1] = 0; @@ -2729,7 +2725,7 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_ bdcpy(sec_event.pin_req.bd_addr, bd_addr); BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class); - BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, (char *)bd_name, (BD_NAME_LEN - 1)); sec_event.pin_req.bd_name[BD_NAME_LEN - 1] = 0; sec_event.pin_req.min_16_digit = min_16_digit; @@ -2899,8 +2895,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data) copy these values into key_notif from cfm_req */ bdcpy(sec_event.key_notif.bd_addr, p_data->cfm_req.bd_addr); BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class, p_data->cfm_req.dev_class); - BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME), - (char *)p_data->cfm_req.bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, (char *)p_data->cfm_req.bd_name, (BD_NAME_LEN - 1)); sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0; } } @@ -2921,8 +2916,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data) } else { bdcpy(sec_event.key_notif.bd_addr, p_data->key_notif.bd_addr); BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class, p_data->key_notif.dev_class); - BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME), - (char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, (char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1)); sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0; } } @@ -2952,7 +2946,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data) bdcpy(sec_event.rmt_oob.bd_addr, p_data->rmt_oob.bd_addr); BTA_COPY_DEVICE_CLASS(sec_event.rmt_oob.dev_class, p_data->rmt_oob.dev_class); - BCM_STRNCPY_S((char *)sec_event.rmt_oob.bd_name, sizeof(BD_NAME), (char *)p_data->rmt_oob.bd_name, (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)sec_event.rmt_oob.bd_name, (char *)p_data->rmt_oob.bd_name, (BD_NAME_LEN - 1)); sec_event.rmt_oob.bd_name[BD_NAME_LEN - 1] = 0; bta_dm_cb.p_sec_cback(BTA_DM_SP_RMT_OOB_EVT, &sec_event); @@ -4288,8 +4282,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D bdcpy(sec_event.ble_req.bd_addr, bda); p_name = BTM_SecReadDevName(bda); if (p_name != NULL) { - BCM_STRNCPY_S((char *)sec_event.ble_req.bd_name, - sizeof(BD_NAME), p_name, (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)sec_event.ble_req.bd_name, p_name, (BD_NAME_LEN)); } else { sec_event.ble_req.bd_name[0] = 0; } @@ -4301,8 +4294,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D bdcpy(sec_event.key_notif.bd_addr, bda); p_name = BTM_SecReadDevName(bda); if (p_name != NULL) { - BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, - sizeof(BD_NAME), p_name, (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, p_name, (BD_NAME_LEN)); } else { sec_event.key_notif.bd_name[0] = 0; } @@ -4323,7 +4315,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D case BTM_LE_NC_REQ_EVT: bdcpy(sec_event.key_notif.bd_addr, bda); - BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, bta_dm_get_remname(), (BD_NAME_LEN)); sec_event.ble_req.bd_name[BD_NAME_LEN] = 0; sec_event.key_notif.passkey = p_data->key_notif; bta_dm_cb.p_sec_cback(BTA_DM_BLE_NC_REQ_EVT, &sec_event); @@ -4343,8 +4335,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D #endif p_name = BTM_SecReadDevName(bda); if (p_name != NULL) { - BCM_STRNCPY_S((char *)sec_event.auth_cmpl.bd_name, - sizeof(BD_NAME), p_name, (BD_NAME_LEN)); + BCM_STRNCPY_S((char *)sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN)); } else { sec_event.auth_cmpl.bd_name[0] = 0; } @@ -5557,7 +5548,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id) /* send result back to app now, one by one */ bdcpy (result.disc_ble_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name,bta_dm_get_remname(), (BD_NAME_LEN - 1)); result.disc_ble_res.bd_name[BD_NAME_LEN] = 0; memcpy(&result.disc_ble_res.service, &service_id.uuid, sizeof(tBT_UUID)); @@ -5599,8 +5590,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status) p_msg->disc_result.result.disc_res.num_uuids = 0; p_msg->disc_result.result.disc_res.p_uuid_list = NULL; bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr); - BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME), - bta_dm_get_remname(), (BD_NAME_LEN - 1)); + BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1)); /* make sure the string is terminated */ p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index df6698172c..7177237229 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -174,7 +174,7 @@ void BTA_DmSetDeviceName(const char *p_name) if ((p_msg = (tBTA_DM_API_SET_NAME *) osi_malloc(sizeof(tBTA_DM_API_SET_NAME))) != NULL) { p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT; /* truncate the name if needed */ - BCM_STRNCPY_S((char *)p_msg->name, sizeof(p_msg->name), p_name, BD_NAME_LEN - 1); + BCM_STRNCPY_S((char *)p_msg->name, p_name, BD_NAME_LEN - 1); p_msg->name[BD_NAME_LEN - 1] = 0; bta_sys_sendmsg(p_msg); diff --git a/components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c b/components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c index 434b2b520c..ea51879c2a 100644 --- a/components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c +++ b/components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c @@ -141,7 +141,7 @@ void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features, p_buf->features = features; p_buf->sec_mask = sec_mask; if (p_service_name) { - BCM_STRNCPY_S(p_buf->name, BTA_SERVICE_NAME_LEN + 1, p_service_name, BTA_SERVICE_NAME_LEN); + BCM_STRNCPY_S(p_buf->name, p_service_name, BTA_SERVICE_NAME_LEN); p_buf->name[BTA_SERVICE_NAME_LEN] = 0; } else { p_buf->name[0] = '\0'; diff --git a/components/bt/bluedroid/stack/avdt/avdt_api.c b/components/bt/bluedroid/stack/avdt/avdt_api.c index 88d3741306..808bd31245 100644 --- a/components/bt/bluedroid/stack/avdt/avdt_api.c +++ b/components/bt/bluedroid/stack/avdt/avdt_api.c @@ -1195,7 +1195,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, len = AVDT_MAX_CNAME_SIZE; } *p++ = (UINT8)len; - BCM_STRNCPY_S((char *)p, len + 1, (char *)p_data->cname, len + 1); + BCM_STRNCPY_S((char *)p, (char *)p_data->cname, AVDT_MAX_CNAME_SIZE + 1); p += len; break; } diff --git a/components/bt/bluedroid/stack/btm/btm_ble.c b/components/bt/bluedroid/stack/btm/btm_ble.c index e11115dd4c..e8d7a2472e 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/bluedroid/stack/btm/btm_ble.c @@ -121,8 +121,7 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d if (bd_name && bd_name[0]) { p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; - BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), - (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); + BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name,(char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); } p_dev_rec->device_type |= dev_type; p_dev_rec->ble.ble_addr_type = addr_type; diff --git a/components/bt/bluedroid/stack/btm/btm_dev.c b/components/bt/bluedroid/stack/btm/btm_dev.c index ae375c9fc0..11d4619411 100644 --- a/components/bt/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/bluedroid/stack/btm/btm_dev.c @@ -107,8 +107,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, if (bd_name && bd_name[0]) { p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; - BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), - (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); + BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); } p_dev_rec->num_read_pages = 0; diff --git a/components/bt/bluedroid/stack/btm/btm_devctl.c b/components/bt/bluedroid/stack/btm/btm_devctl.c index fec42c95ad..adbdbbf066 100644 --- a/components/bt/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/bluedroid/stack/btm/btm_devctl.c @@ -457,7 +457,7 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name) /* Save the device name if local storage is enabled */ p = (UINT8 *)btm_cb.cfg.bd_name; if (p != (UINT8 *)p_name) { - BCM_STRNCPY_S(btm_cb.cfg.bd_name, sizeof(btm_cb.cfg.bd_name), p_name, BTM_MAX_LOC_BD_NAME_LEN); + BCM_STRNCPY_S(btm_cb.cfg.bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN); btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0'; } #else diff --git a/components/bt/bluedroid/stack/btm/btm_sec.c b/components/bt/bluedroid/stack/btm/btm_sec.c index bca9c39d42..ce4e9b04cf 100644 --- a/components/bt/bluedroid/stack/btm/btm_sec.c +++ b/components/bt/bluedroid/stack/btm/btm_sec.c @@ -583,7 +583,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, const char if (is_originator) { p_srec->orig_mx_chan_id = mx_chan_id; #if BTM_SEC_SERVICE_NAME_LEN > 0 - BCM_STRNCPY_S ((char *)p_srec->orig_service_name, sizeof(p_srec->orig_service_name), p_name, BTM_SEC_SERVICE_NAME_LEN); + BCM_STRNCPY_S ((char *)p_srec->orig_service_name, p_name, BTM_SEC_SERVICE_NAME_LEN); #endif /* clear out the old setting, just in case it exists */ #if (L2CAP_UCD_INCLUDED == TRUE) @@ -628,7 +628,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, const char } else { p_srec->term_mx_chan_id = mx_chan_id; #if BTM_SEC_SERVICE_NAME_LEN > 0 - BCM_STRNCPY_S ((char *)p_srec->term_service_name, sizeof(p_srec->term_service_name), p_name, BTM_SEC_SERVICE_NAME_LEN); + BCM_STRNCPY_S ((char *)p_srec->term_service_name, p_name, BTM_SEC_SERVICE_NAME_LEN); #endif /* clear out the old setting, just in case it exists */ #if (L2CAP_UCD_INCLUDED == TRUE) @@ -3010,7 +3010,7 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT if (p_dev_rec) { old_sec_state = p_dev_rec->sec_state; if (status == HCI_SUCCESS) { - BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN); + BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN); p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; BTM_TRACE_EVENT ("setting BTM_SEC_NAME_KNOWN sec_flags:0x%x\n", p_dev_rec->sec_flags); } else { @@ -3506,7 +3506,7 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p) memcpy (evt_data.cfm_req.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN); memcpy (evt_data.cfm_req.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN); - BCM_STRNCPY_S ((char *)evt_data.cfm_req.bd_name, sizeof(evt_data.cfm_req.bd_name), (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN); + BCM_STRNCPY_S ((char *)evt_data.cfm_req.bd_name, (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN); switch (event) { case BTM_SP_CFM_REQ_EVT: @@ -3731,7 +3731,7 @@ void btm_rem_oob_req (UINT8 *p) btm_cb.api.p_sp_callback) { memcpy (evt_data.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN); memcpy (evt_data.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN); - BCM_STRNCPY_S((char *)evt_data.bd_name, sizeof(evt_data.bd_name), (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN + 1); + BCM_STRNCPY_S((char *)evt_data.bd_name, (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN + 1); evt_data.bd_name[BTM_MAX_REM_BD_NAME_LEN] = 0; btm_sec_change_pairing_state(BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP); diff --git a/components/bt/bluedroid/stack/gatt/gatt_utils.c b/components/bt/bluedroid/stack/gatt/gatt_utils.c index fd402825ab..350ebd3c3e 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/bluedroid/stack/gatt/gatt_utils.c @@ -2325,7 +2325,7 @@ void gatt_dbg_display_uuid(tBT_UUID bt_uuid) bt_uuid.uu.uuid128[3], bt_uuid.uu.uuid128[2], bt_uuid.uu.uuid128[1], bt_uuid.uu.uuid128[0]); } else { - BCM_STRNCPY_S(str_buf, sizeof(str_buf), "Unknown UUID 0", 15); + BCM_STRNCPY_S(str_buf, "Unknown UUID 0", 15); } GATT_TRACE_DEBUG ("UUID=[%s]", str_buf); diff --git a/components/bt/bluedroid/stack/include/stack/bt_types.h b/components/bt/bluedroid/stack/include/stack/bt_types.h index ec44cb8719..74d754115b 100644 --- a/components/bt/bluedroid/stack/include/stack/bt_types.h +++ b/components/bt/bluedroid/stack/include/stack/bt_types.h @@ -43,8 +43,8 @@ typedef bool BOOLEAN; #define PACKED __packed // #define INLINE __inline -#define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3)) -#define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4)) +#define BCM_STRCPY_S(x1,x2) strcpy((x1),(x2)) +#define BCM_STRNCPY_S(x1,x2,x3) strncpy((x1),(x2),(x3)) /* READ WELL !! **