Issue:#I7RT23

Signed-off-by: zhoushicheng <zhoushicheng2@huawei.com>
Change-Id: I9dc8793e39c3ca1021b739ad0038bdfc54d50f94
This commit is contained in:
zhoushicheng
2023-08-09 07:47:49 +00:00
parent fdc061cbd3
commit 8697b78271
171 changed files with 291 additions and 1582 deletions
+133 -5
View File
@@ -38,15 +38,10 @@ group("fuzztest") {
"abilitymanagerserviceninth_fuzzer:fuzztest",
# "abilitymanagerservicesecond_fuzzer:fuzztest",
"abilitymanagerfifth_fuzzer:fuzztest",
"abilitymanagerfirst_fuzzer:fuzztest",
"abilitymanagerfourth_fuzzer:fuzztest",
"abilitymanagersecond_fuzzer:fuzztest",
"abilitymanagerserviceseventh_fuzzer:fuzztest",
"abilitymanagerservicesixth_fuzzer:fuzztest",
"abilitymanagerservicetenth_fuzzer:fuzztest",
"abilitymanagerservicethird_fuzzer:fuzztest",
"abilitymanagerthird_fuzzer:fuzztest",
"abilitymgrrest_fuzzer:fuzztest",
"abilityrunningrecord_fuzzer:fuzztest",
"appstateobservermanager_fuzzer:fuzztest",
@@ -199,6 +194,139 @@ group("fuzztest") {
"wantagenthelpertrigger_fuzzer:fuzztest",
# "wantreceiverstub_fuzzer:fuzztest",
"abilitystubabilityrecovery_fuzzer:fuzztest",
"abilitystubabilityrecoveryenable_fuzzer:fuzztest",
"abilitystubabilitytransitiondone_fuzzer:fuzztest",
"abilitystubacquiredataability_fuzzer:fuzztest",
"abilitystubacquiresharedata_fuzzer:fuzztest",
"abilitystubaddfreeinstallobserver_fuzzer:fuzztest",
"abilitystubattachabilitythread_fuzzer:fuzztest",
"abilitystubcallrequestdone_fuzzer:fuzztest",
"abilitystubcalluiabilitybyscb_fuzzer:fuzztest",
"abilitystubcancelwantsender_fuzzer:fuzztest",
"abilitystubcheckuiextensionisfocused_fuzzer:fuzztest",
"abilitystubcleanallmissions_fuzzer:fuzztest",
"abilitystubcleanmission_fuzzer:fuzztest",
"abilitystubclearupapplicationdata_fuzzer:fuzztest",
"abilitystubcloseuiabilitybyscb_fuzzer:fuzztest",
"abilitystubcommandabilitydone_fuzzer:fuzztest",
"abilitystubcommandabilitywindowdone_fuzzer:fuzztest",
"abilitystubcompletefirstframedrawing_fuzzer:fuzztest",
"abilitystubconnectability_fuzzer:fuzztest",
"abilitystubconnectabilitydone_fuzzer:fuzztest",
"abilitystubconnectabilitywithtype_fuzzer:fuzztest",
"abilitystubconnectuiextensionability_fuzzer:fuzztest",
"abilitystubcontinueability_fuzzer:fuzztest",
"abilitystubcontinuemission_fuzzer:fuzztest",
"abilitystubcontinuemissionofbundlename_fuzzer:fuzztest",
"abilitystubdelegatordoabilitybackground_fuzzer:fuzztest",
"abilitystubdelegatordoabilityforeground_fuzzer:fuzztest",
"abilitystubdisconnectability_fuzzer:fuzztest",
"abilitystubdisconnectabilitydone_fuzzer:fuzztest",
"abilitystubdoabilitybackground_fuzzer:fuzztest",
"abilitystubdoabilityforeground_fuzzer:fuzztest",
"abilitystubdumpabilityinfodone_fuzzer:fuzztest",
"abilitystubdumpstate_fuzzer:fuzztest",
"abilitystubdumpsysstate_fuzzer:fuzztest",
"abilitystubfinishusertest_fuzzer:fuzztest",
"abilitystubforceexitapp_fuzzer:fuzztest",
"abilitystubfreeinstallabilityfromremote_fuzzer:fuzztest",
"abilitystubgetabilityrunninginfo_fuzzer:fuzztest",
"abilitystubgetabilitytoken_fuzzer:fuzztest",
"abilitystubgetappmemorysize_fuzzer:fuzztest",
"abilitystubgetdlpconnectioninfos_fuzzer:fuzztest",
"abilitystubgetelementnamebytoken_fuzzer:fuzztest",
"abilitystubgetextensionrunninginfo_fuzzer:fuzztest",
"abilitystubgetmissionidbytoken_fuzzer:fuzztest",
"abilitystubgetmissioninfo_fuzzer:fuzztest",
"abilitystubgetmissioninfos_fuzzer:fuzztest",
"abilitystubgetmissionsnapshotinfo_fuzzer:fuzztest",
"abilitystubgetpendingrequestwant_fuzzer:fuzztest",
"abilitystubgetpendingwantbundlename_fuzzer:fuzztest",
"abilitystubgetpendingwantcode_fuzzer:fuzztest",
"abilitystubgetpendingwanttype_fuzzer:fuzztest",
"abilitystubgetpendingwantuid_fuzzer:fuzztest",
"abilitystubgetpendingwantuserid_fuzzer:fuzztest",
"abilitystubgetprocessrunninginfo_fuzzer:fuzztest",
"abilitystubgettopability_fuzzer:fuzztest",
"abilitystubgettopabilitytoken_fuzzer:fuzztest",
"abilitystubgetwantsender_fuzzer:fuzztest",
"abilitystubgetwantsendinfo_fuzzer:fuzztest",
"abilitystubisramconstraineddevice_fuzzer:fuzztest",
"abilitystubisrunninginstabilitytest_fuzzer:fuzztest",
"abilitystubkillprocess_fuzzer:fuzztest",
"abilitystublockmissionforcleanup_fuzzer:fuzztest",
"abilitystubminimizeability_fuzzer:fuzztest",
"abilitystubminimizeuiabilitybyscb_fuzzer:fuzztest",
"abilitystubminimizeuiextensionability_fuzzer:fuzztest",
"abilitystubmoveabilitytobackground_fuzzer:fuzztest",
"abilitystubmovemissionstobackground_fuzzer:fuzztest",
"abilitystubmovemissionstoforeground_fuzzer:fuzztest",
"abilitystubmovemissiontobackground_fuzzer:fuzztest",
"abilitystubmovemissiontofront_fuzzer:fuzztest",
"abilitystubmovemissiontofrontbyoptions_fuzzer:fuzztest",
"abilitystubnotifycompletecontinuation_fuzzer:fuzztest",
"abilitystubnotifycontinuationresult_fuzzer:fuzztest",
"abilitystubnotifysaveasresult_fuzzer:fuzztest",
"abilitystubprepareterminateability_fuzzer:fuzztest",
"abilitystubquerymissionvaild_fuzzer:fuzztest",
"abilitystubrecordappexitreason_fuzzer:fuzztest",
"abilitystubregistercancellistener_fuzzer:fuzztest",
"abilitystubregistercollaborator_fuzzer:fuzztest",
"abilitystubregisterconnectionobserver_fuzzer:fuzztest",
"abilitystubregistermissionlistener_fuzzer:fuzztest",
"abilitystubregisterremotemissionlistener_fuzzer:fuzztest",
"abilitystubregisterremoteofflistener_fuzzer:fuzztest",
"abilitystubregisterremoteonlistener_fuzzer:fuzztest",
"abilitystubregisterwmshandler_fuzzer:fuzztest",
"abilitystubreleasecallability_fuzzer:fuzztest",
"abilitystubreleasedataability_fuzzer:fuzztest",
"abilitystubreportdrawncompleted_fuzzer:fuzztest",
"abilitystubrequestdialogservice_fuzzer:fuzztest",
"abilitystubsendabilityresultbytoken_fuzzer:fuzztest",
"abilitystubsendanrprocessid_fuzzer:fuzztest",
"abilitystubsendresulttoability_fuzzer:fuzztest",
"abilitystubsendwantsender_fuzzer:fuzztest",
"abilitystubsetabilitycontroller_fuzzer:fuzztest",
"abilitystubsetcomponentinterception_fuzzer:fuzztest",
"abilitystubsetmissioncontinuestate_fuzzer:fuzztest",
"abilitystubsetmissionicon_fuzzer:fuzztest",
"abilitystubsetmissionlabel_fuzzer:fuzztest",
"abilitystubsetrootscenesession_fuzzer:fuzztest",
"abilitystubsetsessionmanagerservice_fuzzer:fuzztest",
"abilitystubsharedatadone_fuzzer:fuzztest",
"abilitystubstartability_fuzzer:fuzztest",
"abilitystubstartabilityaddcaller_fuzzer:fuzztest",
"abilitystubstartabilityascallerbytoken_fuzzer:fuzztest",
"abilitystubstartabilityascallerforoptions_fuzzer:fuzztest",
"abilitystubstartabilitybycall_fuzzer:fuzztest",
"abilitystubstartabilityforoptions_fuzzer:fuzztest",
"abilitystubstartabilityforsettings_fuzzer:fuzztest",
"abilitystubstartcontinuation_fuzzer:fuzztest",
"abilitystubstartextensionability_fuzzer:fuzztest",
"abilitystubstartspecifiedabilitybyscb_fuzzer:fuzztest",
"abilitystubstartsyncmissions_fuzzer:fuzztest",
"abilitystubstartuiabilitybyscb_fuzzer:fuzztest",
"abilitystubstartuiextensionability_fuzzer:fuzztest",
"abilitystubstartuser_fuzzer:fuzztest",
"abilitystubstartusertest_fuzzer:fuzztest",
"abilitystubstopextensionability_fuzzer:fuzztest",
"abilitystubstopserviceability_fuzzer:fuzztest",
"abilitystubstopsyncmissions_fuzzer:fuzztest",
"abilitystubstopuser_fuzzer:fuzztest",
"abilitystubterminateability_fuzzer:fuzztest",
"abilitystubterminatemission_fuzzer:fuzztest",
"abilitystubterminateuiextensionability_fuzzer:fuzztest",
"abilitystubuninstallapp_fuzzer:fuzztest",
"abilitystubunlockmissionforcleanup_fuzzer:fuzztest",
"abilitystubunregistercancellistener_fuzzer:fuzztest",
"abilitystubunregistercollaborator_fuzzer:fuzztest",
"abilitystubunregisterconnectionobserver_fuzzer:fuzztest",
"abilitystubunregistermissionlistener_fuzzer:fuzztest",
"abilitystubunregisterremotemissionlistener_fuzzer:fuzztest",
"abilitystubupdatemissionsnapshot_fuzzer:fuzztest",
"abilitystubupdatemissionsnapshotfromwms_fuzzer:fuzztest",
"abilitystubverifypermission_fuzzer:fuzztest",
"wantsenderstub_fuzzer:fuzztest",
]
}
@@ -1,80 +0,0 @@
# 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.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityManagerFifthFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilitymanagerfifth_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitymanagerfifth_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
if (ecologic_rule_enabled) {
external_deps += [ "ecological_rule_mgr:erms_client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityManagerFifthFuzzTest",
]
}
###############################################################################
@@ -1,147 +0,0 @@
/*
* 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.
*/
#include "abilitymanagerfifth_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include "ability_manager_service.h"
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
#define DISABLE_FUZZ
namespace OHOS {
namespace {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t INPUT_EIGHT = 8;
constexpr size_t INPUT_SIXTEEN = 16;
constexpr size_t INPUT_TWENTYFOUR = 24;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
std::map<int, uint32_t> codeMap_;
uint32_t GetU32Data(const char* ptr)
{
// convert fuzz input data to an integer
return (ptr[INDEX_ZERO] << INPUT_TWENTYFOUR) | (ptr[INDEX_ONE] << INPUT_SIXTEEN) |
(ptr[INDEX_TWO] << INPUT_EIGHT) | ptr[INDEX_THREE];
}
void EmplaceCodeMap()
{
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::STOP_SYNC_MISSIONS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_SNAPSHOT_HANDLER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UPDATE_MISSION_SNAPSHOT));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_FOREGROUND));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_BACKGROUND));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::UPDATE_MISSION_SNAPSHOT_FROM_WMS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_USER_TEST));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::FINISH_USER_TEST));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_FOREGROUND));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_BACKGROUND));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_TOP_ABILITY_TOKEN));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMP_STATE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMPSYS_STATE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::FORCE_TIMEOUT));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_WMS_HANDLER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::COMPLETEFIRSTFRAMEDRAWING));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_CONNECTION_OBSERVER));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_CONNECTION_OBSERVER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_TOP_ABILITY));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::FREE_INSTALL_ABILITY_FROM_REMOTE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ADD_FREE_INSTALL_OBSERVER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_RECOVERY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_RECOVERY_ENABLE));
#ifndef DISABLE_FUZZ
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::QUERY_MISSION_VAILD));
#endif
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::VERIFY_PERMISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ACQUIRE_SHARE_DATA));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SHARE_DATA_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ABILITY_TOKEN));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::FORCE_EXIT_APP));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::RECORD_APP_EXIT_REASON));
}
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
if (codeMap_.size() == 0) {
EmplaceCodeMap();
}
uint32_t code = GetU32Data(data) % codeMap_.size();
code = codeMap_[code];
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -1,21 +0,0 @@
/*
* 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIFTH_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIFTH_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitymanagerfifth_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIFTH_FUZZER_H
@@ -1,16 +0,0 @@
/*
* 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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -1,80 +0,0 @@
# Copyright (c) 2022-2023 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/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityManagerFirstFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilitymanagerfirst_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitymanagerfirst_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
if (ecologic_rule_enabled) {
external_deps += [ "ecological_rule_mgr:erms_client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityManagerFirstFuzzTest",
]
}
###############################################################################
@@ -1,138 +0,0 @@
/*
* 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.
*/
#include "abilitymanagerfirst_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include "ability_manager_service.h"
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t INPUT_EIGHT = 8;
constexpr size_t INPUT_SIXTEEN = 16;
constexpr size_t INPUT_TWENTYFOUR = 24;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
std::map<int, uint32_t> codeMap_;
uint32_t GetU32Data(const char* ptr)
{
// convert fuzz input data to an integer
return (ptr[INDEX_ZERO] << INPUT_TWENTYFOUR) | (ptr[INDEX_ONE] << INPUT_SIXTEEN) |
(ptr[INDEX_TWO] << INPUT_EIGHT) | ptr[INDEX_THREE];
}
void EmplaceCodeMap()
{
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::TERMINATE_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ADD_WINDOW_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::LIST_STACK_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_RECENT_MISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REMOVE_MISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REMOVE_STACK));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::COMMAND_ABILITY_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::ACQUIRE_DATA_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::RELEASE_DATA_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_TOP));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::KILL_PROCESS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UNINSTALL_APP));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_FLOATING_STACK));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_SPLITSCREEN_STACK));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CHANGE_FOCUS_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_MULTI_WINDOW));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MAXIMIZE_MULTI_WINDOW));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_FLOATING_MISSIONS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CLOSE_MULTI_WINDOW));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_END));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::COMPEL_VERIFY_PERMISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::POWER_OFF));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::POWER_ON));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::LUCK_MISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UNLUCK_MISSION));
}
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
if (codeMap_.size() == 0) {
EmplaceCodeMap();
}
uint32_t code = GetU32Data(data) % codeMap_.size();
code = codeMap_[code];
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -1,21 +0,0 @@
/*
* 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIRST_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIRST_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitymanagerfirst_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFIRST_FUZZER_H
@@ -1,16 +0,0 @@
/*
* 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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -1,80 +0,0 @@
# Copyright (c) 2022-2023 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/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityManagerFourthFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilitymanagerfourth_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitymanagerfourth_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
if (ecologic_rule_enabled) {
external_deps += [ "ecological_rule_mgr:erms_client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityManagerFourthFuzzTest",
]
}
###############################################################################
@@ -1,149 +0,0 @@
/*
* 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.
*/
#include "abilitymanagerfourth_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include "ability_manager_service.h"
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t INPUT_EIGHT = 8;
constexpr size_t INPUT_SIXTEEN = 16;
constexpr size_t INPUT_TWENTYFOUR = 24;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
std::map<int, uint32_t> codeMap_;
uint32_t GetU32Data(const char* ptr)
{
// convert fuzz input data to an integer
return (ptr[INDEX_ZERO] << INPUT_TWENTYFOUR) | (ptr[INDEX_ONE] << INPUT_SIXTEEN) |
(ptr[INDEX_TWO] << INPUT_EIGHT) | ptr[INDEX_THREE];
}
void EmplaceCodeMap()
{
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY_FOR_OPTIONS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::BLOCK_AMS_SERVICE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::BLOCK_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::BLOCK_APP_SERVICE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_CALL_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::RELEASE_CALL_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CALL_REQUEST_DONE));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_BY_TOKEN));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_FOR_OPTIONS));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::TERMINATE_UI_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_UI_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_UI_ABILITY_BY_SCB));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_UI_ABILITY_BY_SCB));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CLOSE_UI_ABILITY_BY_SCB));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REQUEST_DIALOG_SERVICE));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::START_SPECIFIED_ABILITY_BY_SCB));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_SESSIONMANAGERSERVICE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_CONTINUATION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::NOTIFY_CONTINUATION_RESULT));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::NOTIFY_COMPLETE_CONTINUATION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_MISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_RESULT_TO_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_REMOTE_ON_LISTENER));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_REMOTE_OFF_LISTENER));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_REMOTE_MISSION_LISTENER));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_REMOTE_MISSION_LISTENER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_SYNC_MISSIONS));
}
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
if (codeMap_.size() == 0) {
EmplaceCodeMap();
}
uint32_t code = GetU32Data(data) % codeMap_.size();
code = codeMap_[code];
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -1,21 +0,0 @@
/*
* 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFOURTH_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFOURTH_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitymanagerfourth_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERFOURTH_FUZZER_H
@@ -1,16 +0,0 @@
/*
* 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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -1,80 +0,0 @@
# Copyright (c) 2022-2023 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/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityManagerSecondFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilitymanagersecond_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitymanagersecond_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
if (ecologic_rule_enabled) {
external_deps += [ "ecological_rule_mgr:erms_client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityManagerSecondFuzzTest",
]
}
###############################################################################
@@ -1,139 +0,0 @@
/*
* 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.
*/
#include "abilitymanagersecond_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include "ability_manager_service.h"
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t INPUT_EIGHT = 8;
constexpr size_t INPUT_SIXTEEN = 16;
constexpr size_t INPUT_TWENTYFOUR = 24;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
std::map<int, uint32_t> codeMap_;
uint32_t GetU32Data(const char* ptr)
{
// convert fuzz input data to an integer
return (ptr[INDEX_ZERO] << INPUT_TWENTYFOUR) | (ptr[INDEX_ONE] << INPUT_SIXTEEN) |
(ptr[INDEX_TWO] << INPUT_EIGHT) | ptr[INDEX_THREE];
}
void EmplaceCodeMap()
{
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_MISSION_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_LOCK_MODE_STATE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::LOCK_MISSION_FOR_CLEANUP));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UNLOCK_MISSION_FOR_CLEANUP));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_MISSION_LISTENER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_MISSION_LISTENER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_INFOS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_INFO_BY_ID));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAN_MISSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAN_ALL_MISSIONS));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_BY_ID));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_USER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::STOP_USER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_ABILITY_CONTROLLER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::IS_USER_A_STABILITY_TEST));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_MISSION_LABEL));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DO_ABILITY_FOREGROUND));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DO_ABILITY_BACKGROUND));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT_BY_OPTIONS));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_ID_BY_ABILITY_TOKEN));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_MISSION_ICON));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMP_ABILITY_INFO_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::STOP_EXTENSION_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_COMPONENT_INTERCEPTION));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_ABILITY_RESULT_BY_TOKEN));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_ROOT_SCENE_SESSION));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::PREPARE_TERMINATE_ABILITY));
}
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
if (codeMap_.size() == 0) {
EmplaceCodeMap();
}
uint32_t code = GetU32Data(data) % codeMap_.size();
code = codeMap_[code];
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -1,21 +0,0 @@
/*
* 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERSECOND_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERSECOND_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitymanagersecond_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERSECOND_FUZZER_H
@@ -1,16 +0,0 @@
/*
* 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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -1,80 +0,0 @@
# Copyright (c) 2022-2023 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/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityManagerThirdFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"${ability_runtime_test_path}/fuzztest/abilitymanagerthird_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitymanagerthird_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
if (ecologic_rule_enabled) {
external_deps += [ "ecological_rule_mgr:erms_client" ]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityManagerThirdFuzzTest",
]
}
###############################################################################
@@ -1,139 +0,0 @@
/*
* 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.
*/
#include "abilitymanagerthird_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include "ability_manager_service.h"
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t U32_AT_SIZE = 4;
constexpr size_t INPUT_EIGHT = 8;
constexpr size_t INPUT_SIXTEEN = 16;
constexpr size_t INPUT_TWENTYFOUR = 24;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
std::map<int, uint32_t> codeMap_;
uint32_t GetU32Data(const char* ptr)
{
// convert fuzz input data to an integer
return (ptr[INDEX_ZERO] << INPUT_TWENTYFOUR) | (ptr[INDEX_ONE] << INPUT_SIXTEEN) |
(ptr[INDEX_TWO] << INPUT_EIGHT) | ptr[INDEX_THREE];
}
void EmplaceCodeMap()
{
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::COMMAND_ABILITY_WINDOW_DONE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CALL_ABILITY_BY_SCB));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_ABILITY_TO_BACKGROUND));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::STOP_SERVICE_ABILITY));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY_ADD_CALLER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_PENDING_WANT_SENDER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CANCEL_PENDING_WANT_SENDER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_UID));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_BUNDLENAME));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_USERID));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_CODE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_CANCEL_LISTENER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_CANCEL_LISTENER));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_SHOW_ON_LOCK_SCREEN));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_APP_NOT_RESPONSE_PROCESS_ID));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::START_ABILITY_FOR_SETTINGS));
codeMap_.emplace(codeMap_.size(),
static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ABILITY_MISSION_SNAPSHOT));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_APP_MEMORY_SIZE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::IS_RAM_CONSTRAINED_DEVICE));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ABILITY_RUNNING_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_EXTENSION_RUNNING_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PROCESS_RUNNING_INFO));
codeMap_.emplace(codeMap_.size(), static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAR_UP_APPLICATION_DATA));
}
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
if (codeMap_.size() == 0) {
EmplaceCodeMap();
}
uint32_t code = GetU32Data(data) % codeMap_.size();
code = codeMap_[code];
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -1,21 +0,0 @@
/*
* 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERTHIRD_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERTHIRD_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitymanagerthird_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERTHIRD_FUZZER_H
@@ -1,16 +0,0 @@
/*
* 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
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ABILITY_RECOVERY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_RECOVERY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ABILITY_RECOVERY_ENABLE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_RECOVERY_ENABLE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ACQUIRE_DATA_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ACQUIRE_DATA_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ACQUIRE_SHARE_DATA;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ACQUIRE_SHARE_DATA);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ADD_FREE_INSTALL_OBSERVER;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ADD_FREE_INSTALL_OBSERVER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CALL_REQUEST_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CALL_REQUEST_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CALL_ABILITY_BY_SCB;
uint32_t code = IAbilityManager::CALL_ABILITY_BY_SCB;
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CANCEL_PENDING_WANT_SENDER;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CANCEL_PENDING_WANT_SENDER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CHECK_UI_EXTENSION_IS_FOCUSED;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CHECK_UI_EXTENSION_IS_FOCUSED);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CLEAN_ALL_MISSIONS;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAN_ALL_MISSIONS);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CLEAN_MISSION;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAN_MISSION);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CLEAR_UP_APPLICATION_DATA;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CLEAR_UP_APPLICATION_DATA);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CLOSE_UI_ABILITY_BY_SCB;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CLOSE_UI_ABILITY_BY_SCB);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::COMMAND_ABILITY_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::COMMAND_ABILITY_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::COMMAND_ABILITY_WINDOW_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::COMMAND_ABILITY_WINDOW_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::COMPLETEFIRSTFRAMEDRAWING;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::COMPLETEFIRSTFRAMEDRAWING);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONNECT_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONNECT_ABILITY_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONNECT_UI_EXTENSION_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONNECT_UI_EXTENSION_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONTINUE_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONTINUE_MISSION;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_MISSION);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_BACKGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_BACKGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_FOREGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_FOREGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DISCONNECT_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DISCONNECT_ABILITY_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DO_ABILITY_BACKGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DO_ABILITY_BACKGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DO_ABILITY_FOREGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DO_ABILITY_FOREGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DUMP_ABILITY_INFO_DONE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMP_ABILITY_INFO_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DUMP_STATE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMP_STATE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::DUMPSYS_STATE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DUMPSYS_STATE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::FINISH_USER_TEST;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::FINISH_USER_TEST);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::FORCE_EXIT_APP;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::FORCE_EXIT_APP);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -19,7 +19,7 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubFreeInstallAbilityRemoteFuzzTest") {
ohos_fuzztest("AbilityStubFreeInstallAbilityFromRemoteFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer"
@@ -73,7 +73,7 @@ group("fuzztest") {
deps = []
deps += [
# deps file
":AbilityStubFreeInstallAbilityRemoteFuzzTest",
":AbilityStubFreeInstallAbilityFromRemoteFuzzTest",
]
}
###############################################################################
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::FREE_INSTALL_ABILITY_FROM_REMOTE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::FREE_INSTALL_ABILITY_FROM_REMOTE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_ABILITY_RUNNING_INFO;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ABILITY_RUNNING_INFO);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_ABILITY_TOKEN;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ABILITY_TOKEN);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_APP_MEMORY_SIZE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_APP_MEMORY_SIZE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_ELEMENT_NAME_BY_TOKEN;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_ELEMENT_NAME_BY_TOKEN);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_EXTENSION_RUNNING_INFO;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_EXTENSION_RUNNING_INFO);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_MISSION_ID_BY_ABILITY_TOKEN;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_ID_BY_ABILITY_TOKEN);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -13,9 +13,9 @@
* limitations under the License.
*/
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYABILITYTOKEN_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYABILITYTOKEN_FUZZER_H
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYTOKEN_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYTOKEN_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubgetmissionidbytoken_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYABILITYTOKEN_FUZZER_H
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBGETMISSIONIDBYTOKEN_FUZZER_H
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_MISSION_INFO_BY_ID;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_INFO_BY_ID);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_MISSION_INFOS;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_INFOS);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -19,7 +19,7 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubMinimizeUIExtensionAbilityFuzzTest") {
ohos_fuzztest("AbilityStubGetMissionSnapShotInfoFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer"
@@ -73,7 +73,7 @@ group("fuzztest") {
deps = []
deps += [
# deps file
":AbilityStubMinimizeUIExtensionAbilityFuzzTest",
":AbilityStubGetMissionSnapShotInfoFuzzTest",
]
}
###############################################################################
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_INFO;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_INFO);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_BUNDLENAME;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_BUNDLENAME);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_CODE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_CODE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_UID;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_UID);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_USERID;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_USERID);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PROCESS_RUNNING_INFO;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PROCESS_RUNNING_INFO);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_TOP_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_TOP_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_TOP_ABILITY_TOKEN;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_TOP_ABILITY_TOKEN);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -19,7 +19,7 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubGetWantSenderInfoFuzzTest") {
ohos_fuzztest("AbilityStubGetWantSendInfoFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
@@ -74,7 +74,7 @@ group("fuzztest") {
deps = []
deps += [
# deps file
":AbilityStubGetWantSenderInfoFuzzTest",
":AbilityStubGetWantSendInfoFuzzTest",
]
}
###############################################################################
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::IS_RAM_CONSTRAINED_DEVICE;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::IS_RAM_CONSTRAINED_DEVICE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::IS_USER_A_STABILITY_TEST;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::IS_USER_A_STABILITY_TEST);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::KILL_PROCESS;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::KILL_PROCESS);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::LOCK_MISSION_FOR_CLEANUP;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::LOCK_MISSION_FOR_CLEANUP);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MINIMIZE_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MINIMIZE_UI_ABILITY_BY_SCB;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_UI_ABILITY_BY_SCB);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -19,10 +19,10 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni")
module_output_path = "ability_runtime/abilitymgr"
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubMinimizeUIExtensionAbilityFuzzTest") {
ohos_fuzztest("AbilityStubMoveAbilityToBackgroundFuzzTest") {
module_out_path = module_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubminimizeuiextensionability_fuzzer"
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubmoveabilitytobackground_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
@@ -30,7 +30,7 @@ ohos_fuzztest("AbilityStubMinimizeUIExtensionAbilityFuzzTest") {
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubminimizeuiextensionability_fuzzer.cpp" ]
sources = [ "abilitystubmoveabilitytobackground_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
@@ -73,7 +73,7 @@ group("fuzztest") {
deps = []
deps += [
# deps file
":AbilityStubMinimizeUIExtensionAbilityFuzzTest",
":AbilityStubMoveAbilityToBackgroundFuzzTest",
]
}
###############################################################################
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "abilitystubminimizeuiextensionability_fuzzer.h"
#include "abilitystubmoveabilitytobackground_fuzzer.h"
#include <cstddef>
#include <cstdint>
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_BACKGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_BACKGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
@@ -33,7 +33,7 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_FOREGROUND;
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_FOREGROUND);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);

Some files were not shown because too many files have changed in this diff Show More