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

Commit 4b7304f2 authored by Rahul Arya's avatar Rahul Arya
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: 254314964

Change-Id: I1902ab7505cd9aa00a01c197bb7f8b168882cd17
parent 9aeb48bb
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -581,6 +581,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) {
@@ -1294,6 +1295,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,
@@ -1510,7 +1512,8 @@ TEST_F(LeImplTest, set_le_suggested_default_data_parameters) {
}

TEST_F(LeImplTest, LeSetDefaultSubrate) {
  le_impl_->LeSetDefaultSubrate(kIntervalMin, kIntervalMax, kLatency, kContinuationNumber, kTimeout);
  le_impl_->LeSetDefaultSubrate(
      kIntervalMin, kIntervalMax, kLatency, kContinuationNumber, kTimeout);
  sync_handler();
  auto view = CreateAclCommandView<LeSetDefaultSubrateView>(hci_layer_->DequeueCommandBytes());
  ASSERT_TRUE(view.IsValid());
+21 −21
Original line number Diff line number Diff line
@@ -928,27 +928,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();
  }
};