1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "audio_adm_fuzzer_common.h" 17 18 using namespace HMOS::Audio; 19 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)20extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 21 { 22 struct DevHandle *(*BindServiceRender)(const char *) = nullptr; 23 char resolvedPath[] = HDF_LIBRARY_FULL_PATH("libhdi_audio_interface_lib_render"); 24 void *PtrHandle = dlopen(resolvedPath, RTLD_LAZY); 25 if (PtrHandle == nullptr) { 26 return -1; 27 } 28 BindServiceRender = (struct DevHandle *(*)(const char *))dlsym(PtrHandle, "AudioBindServiceRender"); 29 if (BindServiceRender == nullptr) { 30 dlclose(PtrHandle); 31 return -1; 32 } 33 uint8_t *dataFuzz = const_cast<uint8_t *>(data); 34 char *bindFuzz = reinterpret_cast<char *>(dataFuzz); 35 BindServiceRender(bindFuzz); 36 dlclose(PtrHandle); 37 return 0; 38 } 39