From 27200cfeed0dbfa7daa7c1825d62df47ad13465d Mon Sep 17 00:00:00 2001
From: Hui Peng <phui@google.com>
Date: Tue, 6 Dec 2022 01:39:17 +0000
Subject: [PATCH] Add regression test for b/260078907

Bug: 260078907
Test: atest net_test_stack_btm
Ignore-AOSP-First: security
Tag: #security
Merged-In: Ie8c6cb188cf7cde94d2f7dc0db04b3de51e08678
Change-Id: Ie8c6cb188cf7cde94d2f7dc0db04b3de51e08678
---
 system/stack/Android.bp                       |  1 +
 .../test/btm/stack_btm_regression_tests.cc    | 43 +++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 system/stack/test/btm/stack_btm_regression_tests.cc

diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 85095aed8c6..2879924df73 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -861,6 +861,7 @@ cc_test {
         "btm/btm_sec.cc",
         "metrics/stack_metrics_logging.cc",
         "test/btm/stack_btm_test.cc",
+        "test/btm/stack_btm_regression_tests.cc",
         "test/btm/peer_packet_types_test.cc",
     ],
     static_libs: [
diff --git a/system/stack/test/btm/stack_btm_regression_tests.cc b/system/stack/test/btm/stack_btm_regression_tests.cc
new file mode 100644
index 00000000000..e771d60508b
--- /dev/null
+++ b/system/stack/test/btm/stack_btm_regression_tests.cc
@@ -0,0 +1,43 @@
+/*
+ *
+ *  Copyright 2022 The Android Open Source Project
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+#include <gtest/gtest.h>
+
+#include "bt_hdr.h"
+#include "btm_ble_api_types.h"
+#include "hci_error_code.h"
+#include "osi/include/allocator.h"
+#include "ble_hci_link_interface.h"
+
+namespace {
+
+class StackBTMRegressionTests : public ::testing::Test {
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+// regression test for b/260078907
+TEST_F(StackBTMRegressionTests,
+       OOB_in_btm_ble_add_resolving_list_entry_complete) {
+  BT_HDR* pevent = (BT_HDR*)osi_calloc(sizeof(BT_HDR));
+  btm_ble_add_resolving_list_entry_complete(pevent->data, 0);
+  osi_free(pevent);
+}
+
+}  // namespace
-- 
GitLab