• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include "btcore/include/hal_util.h"
19 #include "btcore/include/module.h"
20 
21 extern const module_t osi_module;
22 
23 extern "C" {
android_get_exported_namespace(const char *)24 struct android_namespace_t* android_get_exported_namespace(const char*) {
25   return nullptr;
26 }
27 }
28 
29 class BTCoreModuleFuzzer {
30  public:
31   void process();
32 };
33 
process()34 void BTCoreModuleFuzzer::process() {
35   const bt_interface_t* interface;
36   (void)hal_util_load_bt_library(&interface);
37   module_management_start();
38   module_init(&osi_module);
39   (void)module_start_up(&osi_module);
40   (void)get_module(osi_module.name);
41   module_shut_down(&osi_module);
42   module_clean_up(&osi_module);
43   module_management_stop();
44 }
45 
LLVMFuzzerTestOneInput(const uint8_t *,size_t)46 extern "C" int LLVMFuzzerTestOneInput(const uint8_t*, size_t) {
47   BTCoreModuleFuzzer btCoreModuleFuzzer;
48   btCoreModuleFuzzer.process();
49   return 0;
50 }
51