diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 9e07dd63..b5b388af 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -15,9 +15,12 @@ group("fuzztest") { testonly = true deps = [ + "abilityconnectionwrapperstub_fuzzer:fuzztest", + "bundlemanagercallbackstub_fuzzer:fuzztest", "continuationmanager_fuzzer:fuzztest", "distributedschedstub_fuzzer:fuzztest", "distributedwant_fuzzer:fuzztest", "distributedwantparams_fuzzer:fuzztest", + "dmsfreeinstallcallbackstub_fuzzer:fuzztest", ] } diff --git a/test/fuzztest/abilityconnectionwrapperstub_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/BUILD.gn new file mode 100644 index 00000000..c154033b --- /dev/null +++ b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/BUILD.gn @@ -0,0 +1,96 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/dmsfwk/dmsfwk.gni") +ohos_fuzztest("AbilityConnectionWrapperStubFuzzTest") { + module_out_path = module_output_path + + visibility = [ ":*" ] + include_dirs = [ + "${dms_path}/common/include/", + "${dms_path}/interfaces/innerkits/common/include/", + "${dms_path}/services/dtbschedmgr/include/", + "${dms_path}/services/dtbschedmgr/include/collaborate/", + "${dms_path}/services/dtbschedmgr/test/unittest", + "${dms_path}/test/fuzztest/abilityconnectionwrapperstub_fuzzer", + ] + + fuzz_config_file = + "${dms_path}/test/fuzztest/abilityconnectionwrapperstub_fuzzer" + + configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + ] + + sources = [ + "${dms_path}/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp", + "abilityconnectionwrapperstub_fuzzer.cpp", + ] + + deps = [ "${dms_path}/services/dtbschedmgr:distributedschedsvr" ] + + defines = [] + if (dmsfwk_mission_manager) { + defines += [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ] + } + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "ability_runtime:mission_info", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "device_manager:devicemanagersdk", + "device_security_level:dslm_sdk", + "distributed_bundle_framework:dbms_fwk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "hitrace:libhitracechain", + "init:libbegetutil", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +group("fuzztest") { + testonly = true + deps = [ ":AbilityConnectionWrapperStubFuzzTest" ] +} diff --git a/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.cpp b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.cpp new file mode 100644 index 00000000..335e0c59 --- /dev/null +++ b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.cpp @@ -0,0 +1,93 @@ +/* + * 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 "abilityconnectionwrapperstub_fuzzer.h" + +#include "ability_connection_wrapper_stub.h" +#include "mock_distributed_sched.h" +#include "parcel_helper.h" + +namespace OHOS { +namespace DistributedSchedule { +using namespace AAFwk; + +bool OnAbilityConnectDoneFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return false; + } + sptr connection(new MockDistributedSched()); + std::string localDeviceId(reinterpret_cast(data), size); + std::shared_ptr abilityConnection_ = + std::make_shared(connection, localDeviceId); + uint32_t code = IAbilityConnection::ON_ABILITY_CONNECT_DONE; + int32_t resultCode = *(reinterpret_cast(data)); + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + dataParcel.WriteInt32(resultCode); + abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option); + + std::u16string descriptor = IAbilityConnection::GetDescriptor(); + dataParcel.WriteInterfaceToken(descriptor); + abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option); + + std::string str1(reinterpret_cast(data), size); + std::string str2(reinterpret_cast(data), size); + std::string str3(reinterpret_cast(data), size); + AppExecFwk::ElementName element(str1, str2, str3); + dataParcel.WriteParcelable(&element); + abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option); + + dataParcel.WriteRemoteObject(connection); + abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option); + return true; +} + +bool OnAbilityDisconnectDoneFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return false; + } + sptr connection(new MockDistributedSched()); + std::shared_ptr abilityConnection_ = + std::make_shared(connection); + uint32_t code = IAbilityConnection::ON_ABILITY_DISCONNECT_DONE; + int32_t resultCode = *(reinterpret_cast(data)); + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + dataParcel.WriteInt32(resultCode); + std::string str1(reinterpret_cast(data), size); + std::string str2(reinterpret_cast(data), size); + std::string str3(reinterpret_cast(data), size); + std::u16string descriptor = IAbilityConnection::GetDescriptor(); + dataParcel.WriteInterfaceToken(descriptor); + AppExecFwk::ElementName element(str1, str2, str3); + dataParcel.WriteParcelable(&element); + dataParcel.WriteRemoteObject(connection); + abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option); + return true; +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::DistributedSchedule::OnAbilityConnectDoneFuzzTest(data, size); + OHOS::DistributedSchedule::OnAbilityDisconnectDoneFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.h b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.h new file mode 100644 index 00000000..938fa4c3 --- /dev/null +++ b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/abilityconnectionwrapperstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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. + */ + +#ifndef OHOS_ABILITYCONNECTIONWRAPPERSTUB_FUZZER_H +#define OHOS_ABILITYCONNECTIONWRAPPERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityconnectionwrapperstub_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/abilityconnectionwrapperstub_fuzzer/corpus/init b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 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. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityconnectionwrapperstub_fuzzer/project.xml b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/test/fuzztest/abilityconnectionwrapperstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/bundlemanagercallbackstub_fuzzer/BUILD.gn b/test/fuzztest/bundlemanagercallbackstub_fuzzer/BUILD.gn new file mode 100644 index 00000000..ebcb0a78 --- /dev/null +++ b/test/fuzztest/bundlemanagercallbackstub_fuzzer/BUILD.gn @@ -0,0 +1,92 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/dmsfwk/dmsfwk.gni") +ohos_fuzztest("BundleManagerCallBackStubFuzzTest") { + module_out_path = module_output_path + + visibility = [ ":*" ] + include_dirs = [ + "${dms_path}/common/include/", + "${dms_path}/interfaces/innerkits/common/include/", + "${dms_path}/services/dtbschedmgr/include/", + "${dms_path}/services/dtbschedmgr/include/collaborate/", + "${dms_path}/test/fuzztest/bundlemanagercallbackstub_fuzzer", + ] + + fuzz_config_file = + "${dms_path}/test/fuzztest/bundlemanagercallbackstub_fuzzer" + + configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + ] + + sources = [ "bundlemanagercallbackstub_fuzzer.cpp" ] + + deps = [ "${dms_path}/services/dtbschedmgr:distributedschedsvr" ] + + defines = [] + if (dmsfwk_mission_manager) { + defines += [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ] + } + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "ability_runtime:mission_info", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "device_manager:devicemanagersdk", + "device_security_level:dslm_sdk", + "distributed_bundle_framework:dbms_fwk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "hitrace:libhitracechain", + "init:libbegetutil", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +group("fuzztest") { + testonly = true + deps = [ ":BundleManagerCallBackStubFuzzTest" ] +} diff --git a/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.cpp b/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.cpp new file mode 100644 index 00000000..585b5bf7 --- /dev/null +++ b/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.cpp @@ -0,0 +1,58 @@ +/* + * 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 "bundlemanagercallbackstub_fuzzer.h" + +#include "bundle/bundle_manager_callback_stub.h" + +namespace OHOS { +namespace DistributedSchedule { + +bool OnQueryInstallationFinishedInnerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return false; + } + std::shared_ptr bundleManager_ = + std::make_shared(); + uint32_t code = 0; + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + bundleManager_->OnRemoteRequest(code, dataParcel, reply, option); + + std::u16string descriptor = bundleManager_->GetDescriptor(); + dataParcel.WriteInterfaceToken(descriptor); + bundleManager_->OnRemoteRequest(code, dataParcel, reply, option); + + code = static_cast(IDBundleManagerCallbackInterfaceCod::ON_QUERY_INSTALLATION_DONE); + int32_t resultCode = *(reinterpret_cast(data)); + uint32_t versionCode = *(reinterpret_cast(data)); + int32_t missionId = *(reinterpret_cast(data)); + dataParcel.WriteInt32(resultCode); + dataParcel.WriteUint32(versionCode); + dataParcel.WriteInt32(missionId); + bundleManager_->OnRemoteRequest(code, dataParcel, reply, option); + return true; +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::DistributedSchedule::OnQueryInstallationFinishedInnerFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.h b/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.h new file mode 100644 index 00000000..f170353c --- /dev/null +++ b/test/fuzztest/bundlemanagercallbackstub_fuzzer/bundlemanagercallbackstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#ifndef OHOS_BUNDLEMANAGERCALLBACKSTUB_FUZZER_H +#define OHOS_BUNDLEMANAGERCALLBACKSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "bundlemanagercallbackstub_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/bundlemanagercallbackstub_fuzzer/corpus/init b/test/fuzztest/bundlemanagercallbackstub_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/test/fuzztest/bundlemanagercallbackstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 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. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/bundlemanagercallbackstub_fuzzer/project.xml b/test/fuzztest/bundlemanagercallbackstub_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/test/fuzztest/bundlemanagercallbackstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/distributedschedstub_fuzzer/distributedschedstub_fuzzer.cpp b/test/fuzztest/distributedschedstub_fuzzer/distributedschedstub_fuzzer.cpp index b938f7f1..f37a83dc 100644 --- a/test/fuzztest/distributedschedstub_fuzzer/distributedschedstub_fuzzer.cpp +++ b/test/fuzztest/distributedschedstub_fuzzer/distributedschedstub_fuzzer.cpp @@ -41,20 +41,22 @@ bool StartRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size) if ((data == nullptr) || (size < sizeof(int32_t))) { return false; } - FuzzUtil::MockPermission(); int32_t code = static_cast(IDSchedInterfaceCode::START_REMOTE_ABILITY); MessageParcel dataParcel; MessageParcel reply; MessageOption option; Want want; - int32_t callerUid = *(reinterpret_cast(data)); - int32_t requestCode = *(reinterpret_cast(data)); - uint32_t accessToken = *(reinterpret_cast(data)); + sptr connect; + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteParcelable(&want); - dataParcel.WriteInt32(callerUid); - dataParcel.WriteInt32(requestCode); - dataParcel.WriteUint32(accessToken); + PARCEL_WRITE_HELPER(dataParcel, Parcelable, &want); + PARCEL_WRITE_HELPER(dataParcel, RemoteObject, connect); + PARCEL_WRITE_HELPER(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER(dataParcel, Uint32, uint32Data); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); + FuzzUtil::MockPermission(); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); return true; } @@ -70,14 +72,15 @@ void ConnectRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel reply; MessageOption option; Want want; - int32_t callerUid = *(reinterpret_cast(data)); - int32_t callerPid = *(reinterpret_cast(data)); - uint32_t accessToken = *(reinterpret_cast(data)); + sptr connect; + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteParcelable(&want); - dataParcel.WriteInt32(callerUid); - dataParcel.WriteInt32(callerPid); - dataParcel.WriteUint32(accessToken); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -91,11 +94,12 @@ void DisconnectRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - int32_t callerUid = *(reinterpret_cast(data)); - uint32_t accessToken = *(reinterpret_cast(data)); - dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteInt32(callerUid); - dataParcel.WriteUint32(accessToken); + sptr connect; + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -149,15 +153,21 @@ void ContinueMissionInnerFuzzTest(const uint8_t* data, size_t size) return; } FuzzUtil::MockPermission(); + int32_t code = static_cast(IDSchedInterfaceCode::CONTINUE_MISSION); MessageParcel dataParcel; MessageParcel reply; - std::string srcDevId(reinterpret_cast(data), size); - std::string dstDevId(reinterpret_cast(data), size); - int32_t missionId = *(reinterpret_cast(data)); - dataParcel.WriteString(srcDevId); - dataParcel.WriteString(dstDevId); - dataParcel.WriteInt32(missionId); - DistributedSchedService::GetInstance().ContinueMissionInner(dataParcel, reply); + MessageOption option; + int32_t int32Data = *(reinterpret_cast(data)); + std::string str(reinterpret_cast(data), size); + sptr callback; + WantParams wantParams; + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, callback); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &wantParams); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } void ContinueMissionOfBundleNameInnerFuzzTest(const uint8_t* data, size_t size) @@ -166,15 +176,20 @@ void ContinueMissionOfBundleNameInnerFuzzTest(const uint8_t* data, size_t size) return; } FuzzUtil::MockPermission(); + int32_t code = static_cast(IDSchedInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME); MessageParcel dataParcel; MessageParcel reply; - std::string srcDevId(reinterpret_cast(data), size); - std::string dstDevId(reinterpret_cast(data), size); - std::string bundleName(reinterpret_cast(data), size); - dataParcel.WriteString(srcDevId); - dataParcel.WriteString(dstDevId); - dataParcel.WriteString(bundleName); - DistributedSchedService::GetInstance().ContinueMissionOfBundleNameInner(dataParcel, reply); + MessageOption option; + std::string str(reinterpret_cast(data), size); + sptr callback; + WantParams wantParams; + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, callback); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &wantParams); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } void GetMissionInfosInnerFuzzTest(const uint8_t* data, size_t size) @@ -187,9 +202,11 @@ void GetMissionInfosInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - int32_t numMissions = *(reinterpret_cast(data)); + int32_t int32Data = *(reinterpret_cast(data)); + std::string str(reinterpret_cast(data), size); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteInt32(numMissions); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -203,7 +220,11 @@ void RegisterMissionListenerInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -217,7 +238,11 @@ void UnRegisterMissionListenerInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -231,7 +256,13 @@ void StartSyncRemoteMissionsInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + int32_t boolData = *(reinterpret_cast(data)); + int32_t int64Data = *(reinterpret_cast(data)); + std::string str(reinterpret_cast(data), size); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Bool, boolData); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -245,7 +276,9 @@ void StopSyncRemoteMissionsInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + std::string str(reinterpret_cast(data), size); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -277,11 +310,16 @@ void StartRemoteAbilityByCallInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - std::string networkId(reinterpret_cast(data), size); - int32_t missionId = *(reinterpret_cast(data)); + Want want; + sptr obj; + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteString(networkId); - dataParcel.WriteInt32(missionId); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -295,7 +333,11 @@ void ReleaseRemoteAbilityInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + sptr connect; + AppExecFwk::ElementName element; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, connect); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &element); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -305,9 +347,12 @@ void GetDistributedComponentListInnerFuzzTest(const uint8_t* data, size_t size) return; } FuzzUtil::MockPermission(); + int32_t code = static_cast(IDSchedInterfaceCode::GET_DISTRIBUTED_COMPONENT_LIST); MessageParcel dataParcel; MessageParcel reply; - DistributedSchedService::GetInstance().GetDistributedComponentListInner(dataParcel, reply); + MessageOption option; + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } void StartRemoteFreeInstallInnerFuzzTest(const uint8_t* data, size_t size) @@ -320,13 +365,16 @@ void StartRemoteFreeInstallInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - int32_t callerUid = *(reinterpret_cast(data)); - int32_t requestCode = *(reinterpret_cast(data)); - uint32_t accessToken = *(reinterpret_cast(data)); + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); + sptr obj; + Want want; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteInt32(callerUid); - dataParcel.WriteInt32(requestCode); - dataParcel.WriteUint32(accessToken); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -340,9 +388,11 @@ void StartRemoteShareFormInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - std::string deviceId(reinterpret_cast(data), size); + std::string str(reinterpret_cast(data), size); + Want want; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteString(deviceId); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -375,9 +425,11 @@ void RegisterOnListenerInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - std::string type(reinterpret_cast(data), size); + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteString(type); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -391,9 +443,11 @@ void RegisterOffListenerInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; - std::string type(reinterpret_cast(data), size); + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); - dataParcel.WriteString(type); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -407,7 +461,11 @@ void RegisterDSchedEventListenerInnerFuzzTest(const uint8_t* data, size_t size) MessageParcel dataParcel; MessageParcel reply; MessageOption option; + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -421,7 +479,11 @@ void UnRegisterDSchedEventListenerInnerFuzzTest(const uint8_t* data, size_t size MessageParcel dataParcel; MessageParcel reply; MessageOption option; + std::string str(reinterpret_cast(data), size); + sptr obj; dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, RemoteObject, obj); DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } @@ -704,6 +766,74 @@ void NotifyStateChangedFromRemoteInnerFuzzTest(const uint8_t* data, size_t size) } DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); } + +void StartFreeInstallFromRemoteInnerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + int32_t code = static_cast(IDSchedInterfaceCode::START_FREE_INSTALL_FROM_REMOTE); + FuzzUtil::MockPermission(); + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + int32_t int32Data = *(reinterpret_cast(data)); + int32_t int64Data = *(reinterpret_cast(data)); + std::string str(reinterpret_cast(data), size); + std::vector strVector = {str}; + DistributedWant dstbWant; + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &dstbWant); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, StringVector, strVector); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, String, str); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); +} + +void NotifyCompleteFreeInstallFromRemoteInnerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + int32_t code = static_cast(IDSchedInterfaceCode::NOTIFY_COMPLETE_FREE_INSTALL_FROM_REMOTE); + FuzzUtil::MockPermission(); + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + int32_t int32Data = *(reinterpret_cast(data)); + int32_t int64Data = *(reinterpret_cast(data)); + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int64, int64Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); +} + +void StopRemoteExtensionAbilityInner(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + int32_t code = static_cast(IDSchedInterfaceCode::STOP_REMOTE_EXTERNSION_ABILITY); + FuzzUtil::MockPermission(); + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + int32_t int32Data = *(reinterpret_cast(data)); + uint32_t uint32Data = *(reinterpret_cast(data)); + std::string str(reinterpret_cast(data), size); + std::vector strVector = {str}; + Want want; + dataParcel.WriteInterfaceToken(DMS_STUB_INTERFACE_TOKEN); + PARCEL_WRITE_HELPER_NORET(dataParcel, Parcelable, &want); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Uint32, uint32Data); + PARCEL_WRITE_HELPER_NORET(dataParcel, Int32, int32Data); + DistributedSchedService::GetInstance().OnRemoteRequest(code, dataParcel, reply, option); +} } } @@ -745,5 +875,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::DistributedSchedule::NotifyMissionsChangedFromRemoteInnerFuzzTest(data, size); OHOS::DistributedSchedule::ReleaseAbilityFromRemoteInnerFuzzTest(data, size); OHOS::DistributedSchedule::NotifyStateChangedFromRemoteInnerFuzzTest(data, size); + OHOS::DistributedSchedule::StartFreeInstallFromRemoteInnerFuzzTest(data, size); + OHOS::DistributedSchedule::NotifyCompleteFreeInstallFromRemoteInnerFuzzTest(data, size); + OHOS::DistributedSchedule::StopRemoteExtensionAbilityInner(data, size); return 0; } \ No newline at end of file diff --git a/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/BUILD.gn b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/BUILD.gn new file mode 100644 index 00000000..8467e1ec --- /dev/null +++ b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/BUILD.gn @@ -0,0 +1,92 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/dmsfwk/dmsfwk.gni") +ohos_fuzztest("DmsFreeInstallCallBackStubFuzzTest") { + module_out_path = module_output_path + + visibility = [ ":*" ] + include_dirs = [ + "${dms_path}/common/include/", + "${dms_path}/interfaces/innerkits/common/include/", + "${dms_path}/services/dtbschedmgr/include/", + "${dms_path}/services/dtbschedmgr/include/collaborate/", + "${dms_path}/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer", + ] + + fuzz_config_file = + "${dms_path}/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer" + + configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + ] + + sources = [ "dmsfreeinstallcallbackstub_fuzzer.cpp" ] + + deps = [ "${dms_path}/services/dtbschedmgr:distributedschedsvr" ] + + defines = [] + if (dmsfwk_mission_manager) { + defines += [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ] + } + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "ability_runtime:mission_info", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "cJSON:cjson", + "c_utils:utils", + "data_share:datashare_consumer", + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "device_manager:devicemanagersdk", + "device_security_level:dslm_sdk", + "distributed_bundle_framework:dbms_fwk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "hitrace:libhitracechain", + "init:libbegetutil", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + +group("fuzztest") { + testonly = true + deps = [ ":DmsFreeInstallCallBackStubFuzzTest" ] +} diff --git a/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/corpus/init b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 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. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.cpp b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.cpp new file mode 100644 index 00000000..03478d84 --- /dev/null +++ b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * 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 "dmsfreeinstallcallbackstub_fuzzer.h" + +#include "dms_free_install_callback.h" +#include "distributed_sched_interface.h" +#include "parcel_helper.h" + +namespace OHOS { +namespace DistributedSchedule { +namespace { +const uint32_t ONE = 1; +} +bool OnInstallFinishedInnerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return false; + } + int64_t taskId = 0; + IDistributedSched::FreeInstallInfo info; + std::shared_ptr freeInstall_ = + std::make_shared(taskId, info); + uint32_t code = ONE; + MessageParcel dataParcel; + MessageParcel reply; + MessageOption option; + std::u16string descriptor = DmsFreeInstallCallbackStub::GetDescriptor(); + freeInstall_->OnRemoteRequest(code, dataParcel, reply, option); + + dataParcel.WriteInterfaceToken(descriptor); + freeInstall_->OnRemoteRequest(code, dataParcel, reply, option); + + code = static_cast(IDRreeInstallCallbackInterfaceCode::ON_FREE_INSTALL_DONE); + int32_t resultCode = *(reinterpret_cast(data)); + int32_t requestCode = *(reinterpret_cast(data)); + dataParcel.WriteInt32(resultCode); + dataParcel.WriteInt32(requestCode); + freeInstall_->OnRemoteRequest(code, dataParcel, reply, option); + + AAFwk::Want want; + dataParcel.WriteParcelable(&want); + freeInstall_->OnRemoteRequest(code, dataParcel, reply, option); + return true; +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + OHOS::DistributedSchedule::OnInstallFinishedInnerFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.h b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.h new file mode 100644 index 00000000..f28c2f1d --- /dev/null +++ b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/dmsfreeinstallcallbackstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#ifndef OHOS_DMSFREEINSTALLCALLBACKSTUB_FUZZER_H +#define OHOS_DMSFREEINSTALLCALLBACKSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "dmsfreeinstallcallbackstub_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/project.xml b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + +