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

Commit fc56a53c authored by Hui Peng's avatar Hui Peng Committed by Android (Google) Code Review
Browse files

Merge changes Id6224912,I7fcb7c46 into udc-mainline-prod

* changes:
  Add test for the following change
  Fix an OOB bug in parse_gap_data
parents 765f2e72 79853094
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@ void parse_gap_data(const std::vector<uint8_t> &raw_data,
      hci::GapData gap_data;
      uint8_t len = raw_data[offset];

      if (offset + len + 1 > raw_data.size()) {
        break;
      }

      auto begin = raw_data.begin() + offset;
      auto end = begin + len + 1;  // 1 byte for len
      auto data_copy = std::make_shared<std::vector<uint8_t>>(begin, end);
+15 −0
Original line number Diff line number Diff line
@@ -20,10 +20,12 @@
#include <unistd.h>

#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <future>
#include <map>
#include <optional>
#include <vector>

#include "btaa/activity_attribution.h"
#include "btif/include/btif_hh.h"
@@ -50,6 +52,7 @@
#include "main/shim/ble_scanner_interface_impl.h"
#include "main/shim/helpers.h"
#include "main/shim/le_advertising_manager.h"
#include "main/shim/utils.h"
#include "main/shim/le_scanning_manager.h"
#include "os/handler.h"
#include "os/mock_queue.h"
@@ -804,3 +807,15 @@ TEST_F(MainShimTest, DumpsysNeighbor) {

  DumpsysNeighbor(STDOUT_FILENO);
}

// test for b/277590580

using bluetooth::hci::GapData;
TEST(MainShimRegressionTest, OOB_In_StartAdvertisingSet) {
  std::vector<uint8_t> raw_data = {10, 0, 0, 0, 0};
  std::vector<GapData> res;

  bluetooth::shim::parse_gap_data(raw_data, res);

  ASSERT_EQ(res.size(), (size_t) 0);
}