/* * Copyright (c) 2024 Huawei Device Co., Ltd. * 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 "fileaccessextconnection_fuzzer.h" #include #include #include "hilog_wrapper.h" #include "file_access_ext_connection.h" namespace OHOS { using namespace std; using namespace FileAccessFwk; bool OnAbilityConnectDoneFuzzTest(shared_ptr conn) { AppExecFwk::ElementName element; sptr remoteObject = nullptr; conn->OnAbilityConnectDone(element, remoteObject, 0); return true; } bool OnAbilityDisconnectDoneFuzzTest(shared_ptr conn) { AppExecFwk::ElementName element; conn->OnAbilityDisconnectDone(element, 0); return true; } bool IsExtAbilityConnectedFuzzTest(shared_ptr conn) { conn->IsExtAbilityConnected(); return true; } bool GetFileExtProxyFuzzTest(shared_ptr conn) { conn->GetFileExtProxy(); return true; } bool ConnectFileExtAbility(shared_ptr conn) { AAFwk::Want want; sptr remoteObject = nullptr; conn->ConnectFileExtAbility(want, remoteObject); return true; } bool DisconnectFileExtAbility(shared_ptr conn) { conn->DisconnectFileExtAbility(); return true; } } // namespace OHOS /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto conn = std::make_shared(); if (conn == nullptr) { return 0; } OHOS::OnAbilityConnectDoneFuzzTest(conn); OHOS::OnAbilityDisconnectDoneFuzzTest(conn); OHOS::IsExtAbilityConnectedFuzzTest(conn); OHOS::GetFileExtProxyFuzzTest(conn); OHOS::ConnectFileExtAbility(conn); OHOS::DisconnectFileExtAbility(conn); return 0; }