sec_event.auth_cmpl.bd_addr = bd_addr;
p_name = BTM_SecReadDevName(bd_addr);
if (p_name != NULL) {
- memcpy(sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN - 1));
- sec_event.auth_cmpl.bd_name[BD_NAME_LEN - 1] = 0;
+ memcpy(sec_event.auth_cmpl.bd_name, p_name, BD_NAME_LEN);
+ sec_event.auth_cmpl.bd_name[BD_NAME_LEN] = 0;
}
/* taken care of by memset [above]
/* send result back to app now, one by one */
result.disc_ble_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)result.disc_ble_res.bd_name, bta_dm_get_remname(),
- BD_NAME_LEN);
+ BD_NAME_LEN + 1);
result.disc_ble_res.service = service_uuid;
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result);
}
p_msg->disc_result.result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->disc_result.result.disc_res.bd_name,
- bta_dm_get_remname(), BD_NAME_LEN);
+ bta_dm_get_remname(), BD_NAME_LEN + 1);
bta_sys_sendmsg(p_msg);
}
bta_dm_search_cb.services_found;
p_msg->disc_result.result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->disc_result.result.disc_res.bd_name,
- bta_dm_get_remname(), BD_NAME_LEN);
+ bta_dm_get_remname(), BD_NAME_LEN + 1);
bta_sys_sendmsg(p_msg);
}
bta_dm_search_cb.services_found;
p_msg->disc_result.result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->disc_result.result.disc_res.bd_name,
- bta_dm_get_remname(), BD_NAME_LEN);
+ bta_dm_get_remname(), BD_NAME_LEN + 1);
bta_sys_sendmsg(p_msg);
}
p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
p_msg->disc_result.result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->disc_result.result.disc_res.bd_name,
- (char*)bta_dm_search_cb.peer_name, BD_NAME_LEN);
+ (char*)bta_dm_search_cb.peer_name, BD_NAME_LEN + 1);
bta_sys_sendmsg(p_msg);
}
/* if this is what we are looking for */
if (bta_dm_search_cb.peer_bdaddr == bd_addr) {
- rem_name.length = strlen((char*)bd_name);
- if (rem_name.length > (BD_NAME_LEN - 1)) {
- rem_name.length = (BD_NAME_LEN - 1);
- rem_name.remote_bd_name[(BD_NAME_LEN - 1)] = 0;
+ rem_name.length = strlcpy((char*)rem_name.remote_bd_name, (char*)bd_name,
+ BD_NAME_LEN + 1);
+ if (rem_name.length > BD_NAME_LEN) {
+ rem_name.length = BD_NAME_LEN;
}
- strlcpy((char*)rem_name.remote_bd_name, (char*)bd_name, BD_NAME_LEN);
rem_name.status = BTM_SUCCESS;
bta_dm_remname_cback(&rem_name);
/* remote name discovery is done but it could be failed */
bta_dm_search_cb.name_discover_done = true;
strlcpy((char*)bta_dm_search_cb.peer_name,
- (char*)p_remote_name->remote_bd_name, BD_NAME_LEN);
+ (char*)p_remote_name->remote_bd_name, BD_NAME_LEN + 1);
BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
(tBTA_DM_REM_NAME*)osi_malloc(sizeof(tBTA_DM_REM_NAME));
p_msg->result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->result.disc_res.bd_name,
- (char*)p_remote_name->remote_bd_name, BD_NAME_LEN);
+ (char*)p_remote_name->remote_bd_name, BD_NAME_LEN + 1);
p_msg->hdr.event = BTA_DM_REMT_NAME_EVT;
bta_sys_sendmsg(p_msg);
BTA_COPY_DEVICE_CLASS(sec_event.cfm_req.dev_class, bta_dm_cb.pin_dev_class);
if (p_result && p_result->status == BTM_SUCCESS) {
- bytes_to_copy = (p_result->length < (BD_NAME_LEN - 1))
- ? p_result->length
- : (BD_NAME_LEN - 1);
+ bytes_to_copy =
+ (p_result->length < BD_NAME_LEN) ? p_result->length : BD_NAME_LEN;
memcpy(sec_event.cfm_req.bd_name, p_result->remote_bd_name,
bytes_to_copy);
- sec_event.pin_req.bd_name[BD_NAME_LEN - 1] = 0;
+ sec_event.pin_req.bd_name[BD_NAME_LEN] = 0;
} else /* No name found */
sec_event.cfm_req.bd_name[0] = 0;
BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, bta_dm_cb.pin_dev_class);
if (p_result && p_result->status == BTM_SUCCESS) {
- bytes_to_copy = (p_result->length < (BD_NAME_LEN - 1))
- ? p_result->length
- : (BD_NAME_LEN - 1);
+ bytes_to_copy = (p_result->length < BD_NAME_LEN) ? p_result->length
+ : (BD_NAME_LEN - 1);
memcpy(sec_event.pin_req.bd_name, p_result->remote_bd_name,
bytes_to_copy);
- sec_event.pin_req.bd_name[BD_NAME_LEN - 1] = 0;
+ sec_event.pin_req.bd_name[BD_NAME_LEN] = 0;
} else /* No name found */
sec_event.pin_req.bd_name[0] = 0;
sec_event.pin_req.bd_addr = bd_addr;
BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class);
- strlcpy((char*)sec_event.pin_req.bd_name, (char*)bd_name, BD_NAME_LEN);
+ strlcpy((char*)sec_event.pin_req.bd_name, (char*)bd_name, BD_NAME_LEN + 1);
sec_event.pin_req.min_16_digit = min_16_digit;
bta_dm_cb.p_sec_cback(BTA_DM_PIN_REQ_EVT, &sec_event);
p_auth_cmpl->bd_addr = bd_addr;
- memcpy(p_auth_cmpl->bd_name, bd_name, (BD_NAME_LEN - 1));
- p_auth_cmpl->bd_name[BD_NAME_LEN - 1] = 0;
+ memcpy(p_auth_cmpl->bd_name, bd_name, BD_NAME_LEN);
+ p_auth_cmpl->bd_name[BD_NAME_LEN] = 0;
p_auth_cmpl->key_present = true;
p_auth_cmpl->key_type = key_type;
p_auth_cmpl->success = true;
memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
sec_event.auth_cmpl.bd_addr = bd_addr;
- memcpy(sec_event.auth_cmpl.bd_name, bd_name, (BD_NAME_LEN - 1));
- sec_event.auth_cmpl.bd_name[BD_NAME_LEN - 1] = 0;
+ memcpy(sec_event.auth_cmpl.bd_name, bd_name, BD_NAME_LEN);
+ sec_event.auth_cmpl.bd_name[BD_NAME_LEN] = 0;
// Report the BR link key based on the BR/EDR address and type
BTM_ReadDevInfo(bd_addr, &sec_event.auth_cmpl.dev_type,
BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class,
p_data->cfm_req.dev_class);
strlcpy((char*)sec_event.key_notif.bd_name,
- (char*)p_data->cfm_req.bd_name, BD_NAME_LEN);
+ (char*)p_data->cfm_req.bd_name, BD_NAME_LEN + 1);
}
}
BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class,
p_data->key_notif.dev_class);
strlcpy((char*)sec_event.key_notif.bd_name,
- (char*)p_data->key_notif.bd_name, BD_NAME_LEN);
- sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0;
+ (char*)p_data->key_notif.bd_name, BD_NAME_LEN + 1);
+ sec_event.key_notif.bd_name[BD_NAME_LEN] = 0;
}
}
sec_event.ble_req.bd_addr = bda;
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL)
- strlcpy((char*)sec_event.ble_req.bd_name, p_name, BD_NAME_LEN);
+ strlcpy((char*)sec_event.ble_req.bd_name, p_name, BD_NAME_LEN + 1);
else
sec_event.ble_req.bd_name[0] = 0;
bta_dm_cb.p_sec_cback(BTA_DM_BLE_SEC_REQ_EVT, &sec_event);
sec_event.key_notif.bd_addr = bda;
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL)
- strlcpy((char*)sec_event.key_notif.bd_name, p_name, BD_NAME_LEN);
+ strlcpy((char*)sec_event.key_notif.bd_name, p_name, BD_NAME_LEN + 1);
else
sec_event.key_notif.bd_name[0] = 0;
sec_event.key_notif.passkey = p_data->key_notif;
case BTM_LE_NC_REQ_EVT:
sec_event.key_notif.bd_addr = bda;
strlcpy((char*)sec_event.key_notif.bd_name, bta_dm_get_remname(),
- (BD_NAME_LEN));
+ (BD_NAME_LEN + 1));
sec_event.key_notif.passkey = p_data->key_notif;
bta_dm_cb.p_sec_cback(BTA_DM_BLE_NC_REQ_EVT, &sec_event);
break;
&sec_event.auth_cmpl.addr_type);
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL)
- strlcpy((char*)sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN));
+ strlcpy((char*)sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN + 1));
else
sec_event.auth_cmpl.bd_name[0] = 0;
/* send result back to app now, one by one */
result.disc_ble_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)result.disc_ble_res.bd_name, bta_dm_get_remname(),
- BD_NAME_LEN);
+ BD_NAME_LEN + 1);
result.disc_ble_res.service = service_id.uuid;
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result);
p_msg->disc_result.result.disc_res.p_uuid_list = NULL;
p_msg->disc_result.result.disc_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
strlcpy((char*)p_msg->disc_result.result.disc_res.bd_name,
- bta_dm_get_remname(), BD_NAME_LEN);
+ bta_dm_get_remname(), BD_NAME_LEN + 1);
p_msg->disc_result.result.disc_res.device_type |= BT_DEVICE_TYPE_BLE;
const RawAddress& bd_addr = p_pin_req->bd_addr;
memcpy(bd_name.name, p_pin_req->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
if (pairing_cb.state == BT_BOND_STATE_BONDING &&
bd_addr != pairing_cb.bd_addr) {
RawAddress bd_addr = p_ssp_key_notif->bd_addr;
memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
pairing_cb.is_ssp = true;
(tBT_DEVICE_TYPE)dev_type);
bd_addr = p_ssp_key_notif->bd_addr;
memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
pairing_cb.is_ssp = false;
RawAddress bd_addr = p_ble_req->bd_addr;
memcpy(bd_name.name, p_ble_req->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
RawAddress bd_addr = p_pin_req->bd_addr;
memcpy(bd_name.name, p_pin_req->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
pairing_cb.is_le_only = true;
bt_bdname_t bd_name;
memcpy(bd_name.name, p_notif_req->bd_name, BD_NAME_LEN);
+ bd_name.name[BD_NAME_LEN] = '\0';
bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING);
pairing_cb.is_ssp = false;