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

Commit d366cc39 authored by Liang Li's avatar Liang Li Committed by lianglli
Browse files

Add fuzzer for bluetooth socket AIDL

Bug: 342012881
Test: m android.hardware.bluetooth.socket-service_fuzzer
Change-Id: I4324cb5d35ecf4d4bdbc79fd007ae515577ec998
parent 8959c5a7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# Bug component: 27441

include platform/packages/modules/Bluetooth:/OWNERS

jaydenk@google.com
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,25 @@ cc_binary {
    ],
}

cc_fuzz {
    name: "android.hardware.bluetooth.socket-service_fuzzer",
    team: "trendy_team_bluetooth",
    defaults: ["service_fuzzer_defaults"],
    srcs: [
        "fuzzer.cpp",
        "BluetoothSocket.cpp",
    ],
    static_libs: [
        "android.hardware.bluetooth.socket-V1-ndk",
        "liblog",
    ],
    fuzz_config: {
        cc: [
            "jaydenk@google.com",
        ],
    },
}

filegroup {
    name: "manifest_android.hardware.bluetooth.socket-service.default.xml",
    srcs: ["bluetooth-socket-service-default.xml"],
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 <fuzzbinder/libbinder_ndk_driver.h>
#include <fuzzer/FuzzedDataProvider.h>

#include "BluetoothSocket.h"

using ::aidl::android::hardware::bluetooth::socket::impl::BluetoothSocket;
using ::android::fuzzService;
using ::ndk::SharedRefBase;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  auto bluetoothSocketAidl = SharedRefBase::make<BluetoothSocket>();

  fuzzService(bluetoothSocketAidl->asBinder().get(),
              FuzzedDataProvider(data, size));

  return 0;
}