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

Commit e73086e3 authored by Antoine SOULIER's avatar Antoine SOULIER
Browse files

bt_snoop: Add intermediate copy preventing source packet modification

Bug: 335520123
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT, no logical change
Change-Id: I09e126dc1f46a2e87cf754d4ea2bedec55cd291e
parent 65413be0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1187,7 +1187,11 @@ void SnoopLogger::FilterCapturedPacket(
  }
}

void SnoopLogger::Capture(HciPacket& packet, Direction direction, PacketType type) {
void SnoopLogger::Capture(const HciPacket& immutable_packet, Direction direction, PacketType type) {
  //// TODO(b/335520123) update FilterCapture to stop modifying packets ////
  HciPacket mutable_packet(immutable_packet);
  HciPacket& packet = mutable_packet;
  //////////////////////////////////////////////////////////////////////////
  uint64_t timestamp_us =
      std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
          .count();
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ class SnoopLogger : public ::bluetooth::Module {
    OUTGOING,
  };

  void Capture(HciPacket& packet, Direction direction, PacketType type);
  void Capture(const HciPacket& packet, Direction direction, PacketType type);

  // Set a L2CAP channel as acceptlisted, allowing packets with that L2CAP CID
  // to show up in the snoop logs.
+8 −1
Original line number Diff line number Diff line
@@ -1599,6 +1599,13 @@ TEST_F(SnoopLoggerModuleTest, custom_socket_profiles_filtered_hfp_hf_test) {
      0x35, 0x36, 0x37, 0x38, 0x39, 0x22, 0x2c, 0x31, 0x34, 0x35, 0x0d, 0x0a, 0x49,
  };

  std::vector<uint8_t> kExpectedPhoneNumber = {
      0x0b, 0x00, 0x30, 0x00, 0x0c, 0x00, 0x40, 0x30, 0x19, 0xff, 0x4f, 0x01, 0x0d,
      0x0a, 0x2b, 0x43, 0x4c, 0x43, 0x43, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  };

  // Set pbap and map filtering modes
  ASSERT_TRUE(bluetooth::os::SetSystemProperty(
      SnoopLogger::kBtSnoopLogFilterProfilePbapModeProperty,
@@ -1681,7 +1688,7 @@ TEST_F(SnoopLoggerModuleTest, custom_socket_profiles_filtered_hfp_hf_test) {
  ASSERT_TRUE(
      std::memcmp(recv_buf1, &SnoopLoggerCommon::kBtSnoopFileHeader, sizeof(recv_buf1)) == 0);
  ASSERT_EQ(bytes_read, static_cast<int>(expected_data_size));
  ASSERT_TRUE(std::memcmp(recv_buf3, kPhoneNumber.data(), expected_data_size) == 0);
  ASSERT_TRUE(std::memcmp(recv_buf3, kExpectedPhoneNumber.data(), expected_data_size) == 0);

  ASSERT_TRUE(bluetooth::os::SetSystemProperty(
      SnoopLogger::kBtSnoopLogFilterProfileMapModeProperty,