1 /* 2 * Copyright (c) 2025 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 #include "fuzzer.h" 16 17 #include "fuzz_data.h" 18 #include "font_define.h" 19 #include "font_hilog.h" 20 #include "font_service_load_manager.h" 21 22 namespace { ServiceUnInstallFuzz(const std::string & fontName)23void ServiceUnInstallFuzz(const std::string& fontName) 24 { 25 OHOS::sptr<OHOS::Global::FontManager::IFontService> service = OHOS::Global::FontManager::FontServiceLoadManager:: 26 GetInstance()->GetFontServiceAbility(OHOS::Global::FontManager::FONT_SA_ID); 27 if ((service) == nullptr) { 28 FONT_LOGE("Service is null"); 29 return; 30 } 31 int32_t result; 32 (void)service->UninstallFont(fontName, result); 33 } 34 } // namespace 35 36 /* Fuzzer entry point */ LLVMFuzzerTestOneInput(const uint8_t * input,size_t size)37extern "C" int LLVMFuzzerTestOneInput(const uint8_t* input, size_t size) 38 { 39 std::string fontName = NewString(input, size); 40 ServiceUnInstallFuzz(fontName); 41 42 return 0; 43 } 44