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

Commit 372610b1 authored by Rahul Arya's avatar Rahul Arya Committed by William Escande
Browse files

Fix uninitialized memory in controller

These fields are only set in Start(), but that may not be called in
test.

Test: gd unit
Bug: 265213364
Bug: 254314964
Merged-In: I1902ab7505cd9aa00a01c197bb7f8b168882cd17
(cherry picked from commit 4b7304f2)
Change-Id: I5a26e29af4766990d6ae03766a96981a648be6dc
parent 7b219c19
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -573,6 +573,7 @@ class LeImplWithConnectionTest : public LeImplTest {
 protected:
  void SetUp() override {
    LeImplTest::SetUp();
    set_random_device_address_policy();

    EXPECT_CALL(mock_le_connection_callbacks_, OnLeConnectSuccess(_, _))
        .WillOnce([&](AddressWithType addr, std::unique_ptr<LeAclConnection> conn) {
@@ -1286,6 +1287,7 @@ TEST_F(LeImplTest, on_le_event__ENHANCED_CONNECTION_COMPLETE_CENTRAL) {

TEST_F(LeImplTest, on_le_event__ENHANCED_CONNECTION_COMPLETE_PERIPHERAL) {
  EXPECT_CALL(mock_le_connection_callbacks_, OnLeConnectSuccess(_, _)).Times(1);
  set_random_device_address_policy();
  auto command = LeEnhancedConnectionCompleteBuilder::Create(
      ErrorCode::SUCCESS,
      kHciHandle,
+21 −21
Original line number Diff line number Diff line
@@ -870,27 +870,27 @@ struct Controller::impl {

  CompletedAclPacketsCallback acl_credits_callback_{};
  CompletedAclPacketsCallback acl_monitor_credits_callback_{};
  LocalVersionInformation local_version_information_;
  std::array<uint8_t, 64> local_supported_commands_;
  std::vector<uint64_t> extended_lmp_features_array_;
  uint16_t acl_buffer_length_ = 0;
  uint16_t acl_buffers_ = 0;
  uint8_t sco_buffer_length_ = 0;
  uint16_t sco_buffers_ = 0;
  Address mac_address_;
  std::string local_name_;
  LeBufferSize le_buffer_size_;
  LeBufferSize iso_buffer_size_;
  uint64_t le_local_supported_features_;
  uint64_t le_supported_states_;
  uint8_t le_connect_list_size_;
  uint8_t le_resolving_list_size_;
  LeMaximumDataLength le_maximum_data_length_;
  uint16_t le_maximum_advertising_data_length_;
  uint16_t le_suggested_default_data_length_;
  uint8_t le_number_supported_advertising_sets_;
  uint8_t le_periodic_advertiser_list_size_;
  VendorCapabilities vendor_capabilities_;
  LocalVersionInformation local_version_information_{};
  std::array<uint8_t, 64> local_supported_commands_{};
  std::vector<uint64_t> extended_lmp_features_array_{};
  uint16_t acl_buffer_length_{};
  uint16_t acl_buffers_{};
  uint8_t sco_buffer_length_{};
  uint16_t sco_buffers_{};
  Address mac_address_{};
  std::string local_name_{};
  LeBufferSize le_buffer_size_{};
  LeBufferSize iso_buffer_size_{};
  uint64_t le_local_supported_features_{};
  uint64_t le_supported_states_{};
  uint8_t le_connect_list_size_{};
  uint8_t le_resolving_list_size_{};
  LeMaximumDataLength le_maximum_data_length_{};
  uint16_t le_maximum_advertising_data_length_{};
  uint16_t le_suggested_default_data_length_{};
  uint8_t le_number_supported_advertising_sets_{};
  uint8_t le_periodic_advertiser_list_size_{};
  VendorCapabilities vendor_capabilities_{};
};  // namespace hci

Controller::Controller() : impl_(std::make_unique<impl>(*this)) {}
+10 −0
Original line number Diff line number Diff line
@@ -127,6 +127,14 @@ class TestController : public Controller {
    supported_opcodes_.insert(op_code);
  }

  bool SupportsBleExtendedAdvertising() const override {
    return support_ble_extended_advertising_;
  }

  void SetBleExtendedAdvertisingSupport(bool support) {
    support_ble_extended_advertising_ = support;
  }

 protected:
  void Start() override {}
  void Stop() override {}
@@ -134,6 +142,7 @@ class TestController : public Controller {

 private:
  std::set<OpCode> supported_opcodes_{};
  bool support_ble_extended_advertising_ = false;
};

class TestHciLayer : public HciLayer {
@@ -485,6 +494,7 @@ class LeScanningManagerExtendedTest : public LeScanningManagerTest {
    LeScanningManagerTest::SetUp();
    test_controller_->AddSupported(OpCode::LE_SET_EXTENDED_SCAN_PARAMETERS);
    test_controller_->AddSupported(OpCode::LE_SET_EXTENDED_SCAN_ENABLE);
    test_controller_->SetBleExtendedAdvertisingSupport(true);
    start_le_scanning_manager();
  }
};