Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd2cdc6f authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Automerger Merge Worker
Browse files

Don't pass name length around am: 65caee16

parents 2d5683a3 65caee16
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <stddef.h>

#include <cstdint>
#include <string>
#include <vector>

#include "android_bluetooth_flags.h"
@@ -1561,10 +1562,7 @@ static void bta_dm_service_search_remname_cback(const RawAddress& bd_addr,
  /* if this is what we are looking for */
  if (bta_dm_search_cb.peer_bdaddr == bd_addr) {
    rem_name.bd_addr = bd_addr;
    rem_name.length = bd_name_copy(rem_name.remote_bd_name, bd_name);
    if (rem_name.length > BD_NAME_LEN) {
      rem_name.length = BD_NAME_LEN;
    }
    bd_name_copy(rem_name.remote_bd_name, bd_name);
    rem_name.status = BTM_SUCCESS;
    rem_name.hci_status = HCI_SUCCESS;
    bta_dm_remname_cback(&rem_name);
@@ -1583,7 +1581,6 @@ static void bta_dm_service_search_remname_cback(const RawAddress& bd_addr,
      // needed so our response is not ignored, since this corresponds to the
      // actual peer_bdaddr
      rem_name.bd_addr = bta_dm_search_cb.peer_bdaddr;
      rem_name.length = 0;
      rem_name.remote_bd_name[0] = 0;
      rem_name.status = btm_status;
      rem_name.hci_status = HCI_SUCCESS;
@@ -1610,7 +1607,8 @@ static void bta_dm_remname_cback(const tBTM_REMOTE_DEV_NAME* p_remote_name) {
      ADDRESS_TO_LOGGABLE_CSTR(p_remote_name->bd_addr),
      btm_status_text(p_remote_name->status),
      hci_error_code_text(p_remote_name->hci_status),
      p_remote_name->remote_bd_name[0], p_remote_name->length);
      p_remote_name->remote_bd_name[0],
      strnlen((const char*)p_remote_name->remote_bd_name, BD_NAME_LEN));

  if (bta_dm_search_cb.peer_bdaddr == p_remote_name->bd_addr) {
    get_btm_client_interface().security.BTM_SecDeleteRmtNameNotifyCallback(
+3 −9
Original line number Diff line number Diff line
@@ -383,12 +383,10 @@ TEST_F(BtaDmTest, bta_dm_remname_cback__typical) {
  tBTM_REMOTE_DEV_NAME name = {
      .status = BTM_SUCCESS,
      .bd_addr = kRawAddress,
      .length = static_cast<uint16_t>(strlen(kRemoteName)),
      .remote_bd_name = {},
      .hci_status = HCI_SUCCESS,
  };
  strlcpy(reinterpret_cast<char*>(&name.remote_bd_name), kRemoteName,
          strlen(kRemoteName));
  bd_name_from_char_pointer(name.remote_bd_name, kRemoteName);

  mock_btm_client_interface.security.BTM_SecDeleteRmtNameNotifyCallback =
      [](tBTM_RMT_NAME_CALLBACK*) -> bool {
@@ -415,12 +413,10 @@ TEST_F(BtaDmTest, bta_dm_remname_cback__wrong_address) {
  tBTM_REMOTE_DEV_NAME name = {
      .status = BTM_SUCCESS,
      .bd_addr = kRawAddress2,
      .length = static_cast<uint16_t>(strlen(kRemoteName)),
      .remote_bd_name = {},
      .hci_status = HCI_SUCCESS,
  };
  strlcpy(reinterpret_cast<char*>(&name.remote_bd_name), kRemoteName,
          strlen(kRemoteName));
  bd_name_from_char_pointer(name.remote_bd_name, kRemoteName);

  mock_btm_client_interface.security.BTM_SecDeleteRmtNameNotifyCallback =
      [](tBTM_RMT_NAME_CALLBACK*) -> bool {
@@ -443,12 +439,10 @@ TEST_F(BtaDmTest, bta_dm_remname_cback__HCI_ERR_CONNECTION_EXISTS) {
  tBTM_REMOTE_DEV_NAME name = {
      .status = BTM_SUCCESS,
      .bd_addr = RawAddress::kEmpty,
      .length = static_cast<uint16_t>(strlen(kRemoteName)),
      .remote_bd_name = {},
      .hci_status = HCI_ERR_CONNECTION_EXISTS,
  };
  strlcpy(reinterpret_cast<char*>(&name.remote_bd_name), kRemoteName,
          strlen(kRemoteName));
  bd_name_from_char_pointer(name.remote_bd_name, kRemoteName);

  mock_btm_client_interface.security.BTM_SecDeleteRmtNameNotifyCallback =
      [](tBTM_RMT_NAME_CALLBACK*) -> bool {
+2 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@

#include "advertise_data_parser.h"
#include "bt_dev_class.h"
#include "bt_name.h"
#include "bta/dm/bta_dm_disc.h"
#include "bta/include/bta_api.h"
#include "btif/include/stack_manager_t.h"
@@ -2148,7 +2149,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
        }
        bt_property_t properties[] = {{
            .type = BT_PROPERTY_BDNAME,
            .len = (int)strlen((char*)disc_res.bd_name),
            .len = (int)strnlen((char*)disc_res.bd_name, BD_NAME_LEN),
            .val = (void*)disc_res.bd_name,
        }};
        const bt_status_t status = btif_storage_set_remote_device_property(
+1 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include <mutex>

#include "advertise_data_parser.h"
#include "bt_name.h"
#include "btif/include/btif_acl.h"
#include "btif/include/btif_config.h"
#include "common/time_util.h"
@@ -1995,18 +1996,14 @@ void btm_process_remote_name(const RawAddress* bda, const BD_NAME bdn,
      /* Copy the name from the data stream into the return structure */
      /* Note that even if it is not being returned, it is used as a  */
      /*      temporary buffer.                                       */
      rem_name.length = (evt_len < BD_NAME_LEN) ? evt_len : BD_NAME_LEN;
      rem_name.status = BTM_SUCCESS;
      rem_name.hci_status = hci_status;

      bd_name_copy(rem_name.remote_bd_name, bdn);
      rem_name.remote_bd_name[rem_name.length] = 0;
    } else {
      /* If processing a stand alone remote name then report the error in the
         callback */
      rem_name.status = BTM_BAD_VALUE_RET;
      rem_name.hci_status = hci_status;
      rem_name.length = 0;
      rem_name.remote_bd_name[0] = 0;
    }
    /* Reset the remote BAD to zero and call callback if possible */
+0 −1
Original line number Diff line number Diff line
@@ -217,7 +217,6 @@ inline std::string btm_inquiry_cmpl_status_text(
typedef struct {
  tBTM_STATUS status;
  RawAddress bd_addr;
  uint16_t length;
  BD_NAME remote_bd_name;
  tHCI_STATUS hci_status;
} tBTM_REMOTE_DEV_NAME;