mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
/*
|
||||
* 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 "abilitycontext_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_record.h"
|
||||
#define private public
|
||||
#include "ability_context.h"
|
||||
#undef private
|
||||
#include "want.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
AbilityContext abilityContext;
|
||||
// fuzz for want
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
int requestCode = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.StartAbility(*want, requestCode);
|
||||
abilityContext.TerminateAbility(requestCode);
|
||||
sptr<AAFwk::IAbilityConnection> conn = nullptr;
|
||||
abilityContext.ConnectAbility(*want, conn);
|
||||
abilityContext.StopAbility(*want);
|
||||
std::string name(data, size);
|
||||
int mode = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.GetDir(name, mode);
|
||||
std::string bundleName(data, size);
|
||||
int flag = static_cast<int>(GetU32Data(data));
|
||||
int accountId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.CreateBundleContext(bundleName, flag, accountId);
|
||||
std::string permission(data, size);
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
int uid = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.VerifyPermission(permission, pid, uid);
|
||||
std::string permissionName(data, size);
|
||||
std::string des(data, size);
|
||||
abilityContext.GetPermissionDes(permissionName, des);
|
||||
std::vector<std::string> permissions;
|
||||
std::string fileName(data, size);
|
||||
abilityContext.DeleteFile(fileName);
|
||||
std::string deviceId(data, size);
|
||||
std::string abilityName(data, size);
|
||||
std::string moduleName(data, size);
|
||||
abilityContext.SetCallingContext(deviceId, bundleName, abilityName, moduleName);
|
||||
std::shared_ptr<Context> base = nullptr;
|
||||
abilityContext.AttachBaseContext(base);
|
||||
std::string type(data, size);
|
||||
abilityContext.GetExternalFilesDir(type);
|
||||
std::string url(data, size);
|
||||
Uri uri = Uri(url);
|
||||
abilityContext.UnauthUriPermission(permission, uri, uid);
|
||||
int patternId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.SetPattern(patternId);
|
||||
BundleInfo bundleInfo;
|
||||
std::shared_ptr<ContextDeal> deal = nullptr;
|
||||
abilityContext.InitResourceManager(bundleInfo, deal);
|
||||
int resId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.GetString(resId);
|
||||
abilityContext.GetStringArray(resId);
|
||||
abilityContext.GetIntArray(resId);
|
||||
int themeId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.SetTheme(themeId);
|
||||
abilityContext.GetColor(resId);
|
||||
int startId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.TerminateAbilityResult(startId);
|
||||
abilityContext.SetColorMode(mode);
|
||||
std::vector<AAFwk::Want> wants;
|
||||
abilityContext.StartAbilities(wants);
|
||||
return (abilityContext.DisconnectAbility(conn) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "abilitycontext_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_record.h"
|
||||
#define private public
|
||||
#include "ability_context.h"
|
||||
#undef private
|
||||
#include "want.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
AbilityContext abilityContext;
|
||||
// fuzz for want
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
int requestCode = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.StartAbility(*want, requestCode);
|
||||
abilityContext.TerminateAbility(requestCode);
|
||||
sptr<AAFwk::IAbilityConnection> conn = nullptr;
|
||||
abilityContext.ConnectAbility(*want, conn);
|
||||
abilityContext.StopAbility(*want);
|
||||
std::string name(data, size);
|
||||
int mode = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.GetDir(name, mode);
|
||||
std::string bundleName(data, size);
|
||||
int flag = static_cast<int>(GetU32Data(data));
|
||||
int accountId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.CreateBundleContext(bundleName, flag, accountId);
|
||||
std::string permission(data, size);
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
int uid = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.VerifyPermission(permission, pid, uid);
|
||||
std::string permissionName(data, size);
|
||||
std::string des(data, size);
|
||||
abilityContext.GetPermissionDes(permissionName, des);
|
||||
std::vector<std::string> permissions;
|
||||
std::string fileName(data, size);
|
||||
abilityContext.DeleteFile(fileName);
|
||||
std::string deviceId(data, size);
|
||||
std::string abilityName(data, size);
|
||||
std::string moduleName(data, size);
|
||||
abilityContext.SetCallingContext(deviceId, bundleName, abilityName, moduleName);
|
||||
std::shared_ptr<Context> base = nullptr;
|
||||
abilityContext.AttachBaseContext(base);
|
||||
std::string type(data, size);
|
||||
abilityContext.GetExternalFilesDir(type);
|
||||
std::string url(data, size);
|
||||
Uri uri = Uri(url);
|
||||
abilityContext.UnauthUriPermission(permission, uri, uid);
|
||||
int patternId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.SetPattern(patternId);
|
||||
BundleInfo bundleInfo;
|
||||
std::shared_ptr<ContextDeal> deal = nullptr;
|
||||
abilityContext.InitResourceManager(bundleInfo, deal);
|
||||
int resId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.GetString(resId);
|
||||
abilityContext.GetStringArray(resId);
|
||||
abilityContext.GetIntArray(resId);
|
||||
int themeId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.SetTheme(themeId);
|
||||
abilityContext.GetColor(resId);
|
||||
int startId = static_cast<int>(GetU32Data(data));
|
||||
abilityContext.TerminateAbilityResult(startId);
|
||||
abilityContext.SetColorMode(mode);
|
||||
std::vector<AAFwk::Want> wants;
|
||||
abilityContext.StartAbilities(wants);
|
||||
return (abilityContext.DisconnectAbility(conn) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYCONTEXT_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYCONTEXT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilitycontext_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYCONTEXT_FUZZER_H
|
||||
/*
|
||||
* 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_ABILITYCONTEXT_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYCONTEXT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilitycontext_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYCONTEXT_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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,124 +1,124 @@
|
||||
/*
|
||||
* 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 "abilitymgrrest_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "ability_interceptor.h"
|
||||
#include "implicit_start_processor.h"
|
||||
#include "system_dialog_scheduler.h"
|
||||
#undef private
|
||||
#include "inner_mission_info.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
std::string bundleName(data, size);
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
int32_t userId = static_cast<int32_t>(GetU32Data(data));
|
||||
std::shared_ptr<SystemDialogScheduler> systemDialogScheduler = std::make_shared<SystemDialogScheduler>();
|
||||
systemDialogScheduler->GetANRDialogWant(static_cast<int>(userId), pid, *want);
|
||||
std::vector<DialogAppInfo> dialogAppInfos;
|
||||
systemDialogScheduler->GetSelectorParams(dialogAppInfos);
|
||||
int32_t labelId = static_cast<int32_t>(GetU32Data(data));
|
||||
std::string appName(data, size);
|
||||
systemDialogScheduler->GetAppNameFromResource(labelId, bundleName, userId, appName);
|
||||
InnerMissionInfo innerMissionInfo;
|
||||
innerMissionInfo.ToJsonStr();
|
||||
std::string jsonStr(data, size);
|
||||
innerMissionInfo.FromJsonStr(jsonStr);
|
||||
std::vector<std::string> info;
|
||||
innerMissionInfo.Dump(info);
|
||||
nlohmann::json value;
|
||||
std::string node(data, size);
|
||||
JsonType jsonType = JsonType::STRING;
|
||||
return innerMissionInfo.CheckJsonNode(value, node, jsonType);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "abilitymgrrest_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "ability_interceptor.h"
|
||||
#include "implicit_start_processor.h"
|
||||
#include "system_dialog_scheduler.h"
|
||||
#undef private
|
||||
#include "inner_mission_info.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
std::string bundleName(data, size);
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
int32_t userId = static_cast<int32_t>(GetU32Data(data));
|
||||
std::shared_ptr<SystemDialogScheduler> systemDialogScheduler = std::make_shared<SystemDialogScheduler>();
|
||||
systemDialogScheduler->GetANRDialogWant(static_cast<int>(userId), pid, *want);
|
||||
std::vector<DialogAppInfo> dialogAppInfos;
|
||||
systemDialogScheduler->GetSelectorParams(dialogAppInfos);
|
||||
int32_t labelId = static_cast<int32_t>(GetU32Data(data));
|
||||
std::string appName(data, size);
|
||||
systemDialogScheduler->GetAppNameFromResource(labelId, bundleName, userId, appName);
|
||||
InnerMissionInfo innerMissionInfo;
|
||||
innerMissionInfo.ToJsonStr();
|
||||
std::string jsonStr(data, size);
|
||||
innerMissionInfo.FromJsonStr(jsonStr);
|
||||
std::vector<std::string> info;
|
||||
innerMissionInfo.Dump(info);
|
||||
nlohmann::json value;
|
||||
std::string node(data, size);
|
||||
JsonType jsonType = JsonType::STRING;
|
||||
return innerMissionInfo.CheckJsonNode(value, node, jsonType);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRREST_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRREST_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilitymgrrest_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRREST_FUZZER_H
|
||||
/*
|
||||
* 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_ABILITYMGRREST_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRREST_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilitymgrrest_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMGRREST_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
|
||||
@@ -1,137 +1,137 @@
|
||||
/*
|
||||
* 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 "abilityrunningrecord_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_running_record.h"
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AbilityInfo> info;
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
AbilityRunningRecord abilityRecord(info, token);
|
||||
Parcel wantParcel;
|
||||
std::shared_ptr<Want> want = nullptr;
|
||||
abilityRecord.SetWant(want);
|
||||
AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_READY;
|
||||
abilityRecord.SetState(state);
|
||||
sptr<IRemoteObject> pretoken = GetFuzzAbilityToken();
|
||||
abilityRecord.SetPreToken(pretoken);
|
||||
int32_t visibility = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetVisibility(visibility);
|
||||
int32_t perceptibility = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetPerceptibility(perceptibility);
|
||||
int32_t connectionState = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetConnectionState(connectionState);
|
||||
int64_t eventId = static_cast<int64_t>(GetU32Data(data));
|
||||
abilityRecord.SetEventId(eventId);
|
||||
int32_t ownerUserId = static_cast<int64_t>(GetU32Data(data));
|
||||
abilityRecord.SetOwnerUserId(ownerUserId);
|
||||
bool flag = *data % ENABLE;
|
||||
abilityRecord.SetIsSingleUser(flag);
|
||||
bool isFocus = *data % ENABLE;
|
||||
abilityRecord.UpdateFocusState(isFocus);
|
||||
abilityRecord.GetName();
|
||||
abilityRecord.GetAbilityInfo();
|
||||
abilityRecord.GetWant();
|
||||
abilityRecord.GetToken();
|
||||
abilityRecord.GetState();
|
||||
abilityRecord.GetLastLaunchTime();
|
||||
abilityRecord.GetPreToken();
|
||||
abilityRecord.GetVisibility();
|
||||
abilityRecord.GetPerceptibility();
|
||||
abilityRecord.GetConnectionState();
|
||||
abilityRecord.GetEventId();
|
||||
abilityRecord.SetTerminating();
|
||||
abilityRecord.IsTerminating();
|
||||
abilityRecord.GetOwnerUserId();
|
||||
abilityRecord.IsSingleUser();
|
||||
abilityRecord.GetFocusFlag();
|
||||
return abilityRecord.IsSameState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "abilityrunningrecord_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_running_record.h"
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AbilityInfo> info;
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
AbilityRunningRecord abilityRecord(info, token);
|
||||
Parcel wantParcel;
|
||||
std::shared_ptr<Want> want = nullptr;
|
||||
abilityRecord.SetWant(want);
|
||||
AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_READY;
|
||||
abilityRecord.SetState(state);
|
||||
sptr<IRemoteObject> pretoken = GetFuzzAbilityToken();
|
||||
abilityRecord.SetPreToken(pretoken);
|
||||
int32_t visibility = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetVisibility(visibility);
|
||||
int32_t perceptibility = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetPerceptibility(perceptibility);
|
||||
int32_t connectionState = static_cast<int32_t>(GetU32Data(data));
|
||||
abilityRecord.SetConnectionState(connectionState);
|
||||
int64_t eventId = static_cast<int64_t>(GetU32Data(data));
|
||||
abilityRecord.SetEventId(eventId);
|
||||
int32_t ownerUserId = static_cast<int64_t>(GetU32Data(data));
|
||||
abilityRecord.SetOwnerUserId(ownerUserId);
|
||||
bool flag = *data % ENABLE;
|
||||
abilityRecord.SetIsSingleUser(flag);
|
||||
bool isFocus = *data % ENABLE;
|
||||
abilityRecord.UpdateFocusState(isFocus);
|
||||
abilityRecord.GetName();
|
||||
abilityRecord.GetAbilityInfo();
|
||||
abilityRecord.GetWant();
|
||||
abilityRecord.GetToken();
|
||||
abilityRecord.GetState();
|
||||
abilityRecord.GetLastLaunchTime();
|
||||
abilityRecord.GetPreToken();
|
||||
abilityRecord.GetVisibility();
|
||||
abilityRecord.GetPerceptibility();
|
||||
abilityRecord.GetConnectionState();
|
||||
abilityRecord.GetEventId();
|
||||
abilityRecord.SetTerminating();
|
||||
abilityRecord.IsTerminating();
|
||||
abilityRecord.GetOwnerUserId();
|
||||
abilityRecord.IsSingleUser();
|
||||
abilityRecord.GetFocusFlag();
|
||||
return abilityRecord.IsSameState(state);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilityrunningrecord_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
/*
|
||||
* 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_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilityrunningrecord_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYRUNNINGRECORD_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
|
||||
@@ -1,146 +1,146 @@
|
||||
/*
|
||||
* 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 "amsmgrscheduler_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "ams_mgr_scheduler.h"
|
||||
#undef private
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AppMgrServiceInner> mgrServiceInner;
|
||||
std::shared_ptr<AMSEventHandler> handler;
|
||||
AmsMgrScheduler amsMgrScheduler(mgrServiceInner, handler);
|
||||
sptr<IStartSpecifiedAbilityResponse> response;
|
||||
amsMgrScheduler.RegisterStartSpecifiedAbilityResponse(response);
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
sptr<IRemoteObject> preToken = nullptr;
|
||||
std::shared_ptr<AbilityInfo> abilityInfoptr;
|
||||
std::shared_ptr<ApplicationInfo> appInfo;
|
||||
std::shared_ptr<AAFwk::Want> wantptr;
|
||||
amsMgrScheduler.LoadAbility(token, preToken, abilityInfoptr, appInfo, wantptr);
|
||||
AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_READY;
|
||||
amsMgrScheduler.UpdateAbilityState(token, state);
|
||||
AppExecFwk::ExtensionState extensionState = AppExecFwk::ExtensionState::EXTENSION_STATE_READY;
|
||||
amsMgrScheduler.UpdateExtensionState(token, extensionState);
|
||||
bool clearMissionFlag = *data % ENABLE;
|
||||
amsMgrScheduler.TerminateAbility(token, clearMissionFlag);
|
||||
sptr<IAppStateCallback> callback;
|
||||
amsMgrScheduler.RegisterAppStateCallback(callback);
|
||||
int32_t visibility = static_cast<int32_t>(GetU32Data(data));
|
||||
int32_t perceptibility = static_cast<int32_t>(GetU32Data(data));
|
||||
int32_t connectionState = static_cast<int32_t>(GetU32Data(data));
|
||||
amsMgrScheduler.AbilityBehaviorAnalysis(token, preToken, visibility, perceptibility, connectionState);
|
||||
int32_t userId = static_cast<int32_t>(GetU32Data(data));
|
||||
amsMgrScheduler.KillProcessesByUserId(userId);
|
||||
std::string bundleName(data, size);
|
||||
int accountId = static_cast<int>(GetU32Data(data));
|
||||
amsMgrScheduler.KillProcessWithAccount(bundleName, accountId);
|
||||
amsMgrScheduler.AbilityAttachTimeOut(token);
|
||||
amsMgrScheduler.PrepareTerminate(token);
|
||||
amsMgrScheduler.KillApplication(bundleName);
|
||||
int uid = static_cast<int>(GetU32Data(data));
|
||||
amsMgrScheduler.KillApplicationByUid(bundleName, uid);
|
||||
amsMgrScheduler.KillApplicationSelf();
|
||||
AppExecFwk::RunningProcessInfo info;
|
||||
amsMgrScheduler.GetRunningProcessInfoByToken(token, info);
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
AbilityInfo abilityInfo;
|
||||
amsMgrScheduler.StartSpecifiedAbility(*want, abilityInfo);
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
AppExecFwk::ApplicationInfo application;
|
||||
bool debug;
|
||||
amsMgrScheduler.GetApplicationInfoByProcessID(pid, application, debug);
|
||||
return amsMgrScheduler.IsReady();
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "amsmgrscheduler_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "ams_mgr_scheduler.h"
|
||||
#undef private
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AppMgrServiceInner> mgrServiceInner;
|
||||
std::shared_ptr<AMSEventHandler> handler;
|
||||
AmsMgrScheduler amsMgrScheduler(mgrServiceInner, handler);
|
||||
sptr<IStartSpecifiedAbilityResponse> response;
|
||||
amsMgrScheduler.RegisterStartSpecifiedAbilityResponse(response);
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
sptr<IRemoteObject> preToken = nullptr;
|
||||
std::shared_ptr<AbilityInfo> abilityInfoptr;
|
||||
std::shared_ptr<ApplicationInfo> appInfo;
|
||||
std::shared_ptr<AAFwk::Want> wantptr;
|
||||
amsMgrScheduler.LoadAbility(token, preToken, abilityInfoptr, appInfo, wantptr);
|
||||
AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_READY;
|
||||
amsMgrScheduler.UpdateAbilityState(token, state);
|
||||
AppExecFwk::ExtensionState extensionState = AppExecFwk::ExtensionState::EXTENSION_STATE_READY;
|
||||
amsMgrScheduler.UpdateExtensionState(token, extensionState);
|
||||
bool clearMissionFlag = *data % ENABLE;
|
||||
amsMgrScheduler.TerminateAbility(token, clearMissionFlag);
|
||||
sptr<IAppStateCallback> callback;
|
||||
amsMgrScheduler.RegisterAppStateCallback(callback);
|
||||
int32_t visibility = static_cast<int32_t>(GetU32Data(data));
|
||||
int32_t perceptibility = static_cast<int32_t>(GetU32Data(data));
|
||||
int32_t connectionState = static_cast<int32_t>(GetU32Data(data));
|
||||
amsMgrScheduler.AbilityBehaviorAnalysis(token, preToken, visibility, perceptibility, connectionState);
|
||||
int32_t userId = static_cast<int32_t>(GetU32Data(data));
|
||||
amsMgrScheduler.KillProcessesByUserId(userId);
|
||||
std::string bundleName(data, size);
|
||||
int accountId = static_cast<int>(GetU32Data(data));
|
||||
amsMgrScheduler.KillProcessWithAccount(bundleName, accountId);
|
||||
amsMgrScheduler.AbilityAttachTimeOut(token);
|
||||
amsMgrScheduler.PrepareTerminate(token);
|
||||
amsMgrScheduler.KillApplication(bundleName);
|
||||
int uid = static_cast<int>(GetU32Data(data));
|
||||
amsMgrScheduler.KillApplicationByUid(bundleName, uid);
|
||||
amsMgrScheduler.KillApplicationSelf();
|
||||
AppExecFwk::RunningProcessInfo info;
|
||||
amsMgrScheduler.GetRunningProcessInfoByToken(token, info);
|
||||
Parcel wantParcel;
|
||||
Want *want = nullptr;
|
||||
if (wantParcel.WriteBuffer(data, size)) {
|
||||
want = Want::Unmarshalling(wantParcel);
|
||||
}
|
||||
AbilityInfo abilityInfo;
|
||||
amsMgrScheduler.StartSpecifiedAbility(*want, abilityInfo);
|
||||
int pid = static_cast<int>(GetU32Data(data));
|
||||
AppExecFwk::ApplicationInfo application;
|
||||
bool debug;
|
||||
amsMgrScheduler.GetApplicationInfoByProcessID(pid, application, debug);
|
||||
return amsMgrScheduler.IsReady();
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMGRSCHEDULER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMGRSCHEDULER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "amsmgrscheduler_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMGRSCHEDULER_FUZZER_H
|
||||
/*
|
||||
* 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_AMSMGRSCHEDULER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMGRSCHEDULER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "amsmgrscheduler_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMGRSCHEDULER_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
|
||||
@@ -1,124 +1,124 @@
|
||||
/*
|
||||
* 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 "applifecycledeal_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "app_lifecycle_deal.h"
|
||||
#include "ability_record.h"
|
||||
#include "message_parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
AppLifeCycleDeal appLifeCycleDeal;
|
||||
sptr<IAppScheduler> thread = nullptr;
|
||||
appLifeCycleDeal.SetApplicationClient(thread);
|
||||
std::shared_ptr<AbilityRunningRecord> ability = nullptr;
|
||||
appLifeCycleDeal.LaunchAbility(ability);
|
||||
AppLaunchData launchData;
|
||||
Configuration config;
|
||||
appLifeCycleDeal.LaunchApplication(launchData, config);
|
||||
HapModuleInfo abilityStage;
|
||||
appLifeCycleDeal.AddAbilityStage(abilityStage);
|
||||
int32_t timeLevel = static_cast<int32_t>(GetU32Data(data));
|
||||
appLifeCycleDeal.ScheduleTrimMemory(timeLevel);
|
||||
int32_t level = static_cast<int32_t>(GetU32Data(data));
|
||||
appLifeCycleDeal.ScheduleMemoryLevel(level);
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
appLifeCycleDeal.ScheduleCleanAbility(token);
|
||||
Want want;
|
||||
std::string bundleName(data, size);
|
||||
appLifeCycleDeal.ScheduleAcceptWant(want, bundleName);
|
||||
sptr<IQuickFixCallback> callback = nullptr;
|
||||
appLifeCycleDeal.NotifyLoadRepairPatch(bundleName, callback);
|
||||
appLifeCycleDeal.NotifyHotReloadPage(callback);
|
||||
appLifeCycleDeal.NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
appLifeCycleDeal.GetApplicationClient();
|
||||
appLifeCycleDeal.LowMemoryWarning();
|
||||
appLifeCycleDeal.ScheduleForegroundRunning();
|
||||
appLifeCycleDeal.ScheduleBackgroundRunning();
|
||||
appLifeCycleDeal.ScheduleProcessSecurityExit();
|
||||
appLifeCycleDeal.ScheduleTerminate();
|
||||
return (appLifeCycleDeal.UpdateConfiguration(config) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
/*
|
||||
* 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 "applifecycledeal_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "app_lifecycle_deal.h"
|
||||
#include "ability_record.h"
|
||||
#include "message_parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
AppLifeCycleDeal appLifeCycleDeal;
|
||||
sptr<IAppScheduler> thread = nullptr;
|
||||
appLifeCycleDeal.SetApplicationClient(thread);
|
||||
std::shared_ptr<AbilityRunningRecord> ability = nullptr;
|
||||
appLifeCycleDeal.LaunchAbility(ability);
|
||||
AppLaunchData launchData;
|
||||
Configuration config;
|
||||
appLifeCycleDeal.LaunchApplication(launchData, config);
|
||||
HapModuleInfo abilityStage;
|
||||
appLifeCycleDeal.AddAbilityStage(abilityStage);
|
||||
int32_t timeLevel = static_cast<int32_t>(GetU32Data(data));
|
||||
appLifeCycleDeal.ScheduleTrimMemory(timeLevel);
|
||||
int32_t level = static_cast<int32_t>(GetU32Data(data));
|
||||
appLifeCycleDeal.ScheduleMemoryLevel(level);
|
||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||
appLifeCycleDeal.ScheduleCleanAbility(token);
|
||||
Want want;
|
||||
std::string bundleName(data, size);
|
||||
appLifeCycleDeal.ScheduleAcceptWant(want, bundleName);
|
||||
sptr<IQuickFixCallback> callback = nullptr;
|
||||
appLifeCycleDeal.NotifyLoadRepairPatch(bundleName, callback);
|
||||
appLifeCycleDeal.NotifyHotReloadPage(callback);
|
||||
appLifeCycleDeal.NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
appLifeCycleDeal.GetApplicationClient();
|
||||
appLifeCycleDeal.LowMemoryWarning();
|
||||
appLifeCycleDeal.ScheduleForegroundRunning();
|
||||
appLifeCycleDeal.ScheduleBackgroundRunning();
|
||||
appLifeCycleDeal.ScheduleProcessSecurityExit();
|
||||
appLifeCycleDeal.ScheduleTerminate();
|
||||
return (appLifeCycleDeal.UpdateConfiguration(config) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_APPLIFECYCLEDEAL_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPLIFECYCLEDEAL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "applifecycledeal_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPLIFECYCLEDEAL_FUZZER_H
|
||||
/*
|
||||
* 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_APPLIFECYCLEDEAL_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPLIFECYCLEDEAL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "applifecycledeal_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPLIFECYCLEDEAL_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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,168 +1,168 @@
|
||||
/*
|
||||
* 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 "appmgrrest_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "app_death_recipient.h"
|
||||
#include "app_mgr_service_event_handler.h"
|
||||
#include "app_process_manager.h"
|
||||
#define private public
|
||||
#include "app_spawn_client.h"
|
||||
#include "app_spawn_msg_wrapper.h"
|
||||
#undef private
|
||||
#include "app_spawn_socket.h"
|
||||
#include "remote_client_manager.h"
|
||||
#include "window_focus_changed_listener.h"
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
sptr<AppDeathRecipient> appDeathRecipient = new AppDeathRecipient();
|
||||
wptr<IRemoteObject> remote;
|
||||
appDeathRecipient->OnRemoteDied(remote);
|
||||
std::shared_ptr<AMSEventHandler> handler;
|
||||
appDeathRecipient->SetEventHandler(handler);
|
||||
std::shared_ptr<AppMgrServiceInner> serviceInner;
|
||||
appDeathRecipient->SetAppMgrServiceInner(serviceInner);
|
||||
bool isRenderProcess = *data % ENABLE;
|
||||
appDeathRecipient->SetIsRenderProcess(isRenderProcess);
|
||||
AppProcessManager appProcessManager;
|
||||
std::shared_ptr<AppTaskInfo> appTaskInfo;
|
||||
appProcessManager.RemoveAppFromRecentList(appTaskInfo);
|
||||
std::string appName(data, size);
|
||||
std::string processName(data, size);
|
||||
pid_t pid = static_cast<pid_t>(GetU32Data(data));
|
||||
int32_t recordId = static_cast<int32_t>(GetU32Data(data));
|
||||
appProcessManager.AddAppToRecentList(appName, processName, pid, recordId);
|
||||
appProcessManager.PushAppFront(recordId);
|
||||
appProcessManager.GetAppTaskInfoById(recordId);
|
||||
std::string bundleName(data, size);
|
||||
appProcessManager.GetAppTaskInfoByProcessName(appName, bundleName);
|
||||
appProcessManager.GetRecentAppList();
|
||||
appProcessManager.RemoveAppFromRecentListById(recordId);
|
||||
appProcessManager.ClearRecentAppList();
|
||||
AppSpawnClient appSpawnClient;
|
||||
appSpawnClient.OpenConnection();
|
||||
std::shared_ptr<AppSpawnSocket> socket;
|
||||
appSpawnClient.SetSocket(socket);
|
||||
appSpawnClient.PreStartNWebSpawnProcess();
|
||||
appSpawnClient.PreStartNWebSpawnProcessImpl();
|
||||
AppSpawnStartMsg startMsg;
|
||||
appSpawnClient.StartProcess(startMsg, pid);
|
||||
int status = static_cast<int>(GetU32Data(data));
|
||||
appSpawnClient.GetRenderProcessTerminationStatus(startMsg, status);
|
||||
appSpawnClient.QueryConnectionState();
|
||||
appSpawnClient.CloseConnection();
|
||||
AppSpawnMsgWrapper appSpawnMsgWrapper;
|
||||
appSpawnMsgWrapper.AssembleMsg(startMsg);
|
||||
appSpawnMsgWrapper.VerifyMsg(startMsg);
|
||||
appSpawnMsgWrapper.DumpMsg();
|
||||
appSpawnMsgWrapper.FreeMsg();
|
||||
AppSpawnSocket appSpawnSocket;
|
||||
std::shared_ptr<OHOS::AppSpawn::ClientSocket> clientSocket;
|
||||
appSpawnSocket.SetClientSocket(clientSocket);
|
||||
appSpawnSocket.OpenAppSpawnConnection();
|
||||
int32_t len = appSpawnMsgWrapper.GetMsgLength();
|
||||
appSpawnSocket.WriteMessage(appSpawnMsgWrapper.GetMsgBuf(), len);
|
||||
appSpawnSocket.ReadMessage(reinterpret_cast<void *>(*data), len);
|
||||
appSpawnSocket.CloseAppSpawnConnection();
|
||||
RemoteClientManager remoteClientManager;
|
||||
sptr<IBundleMgr> bundleManager = nullptr;
|
||||
remoteClientManager.SetBundleManager(bundleManager);
|
||||
std::shared_ptr<AppSpawnClient> appSpawnClientptr;
|
||||
remoteClientManager.SetSpawnClient(appSpawnClientptr);
|
||||
remoteClientManager.GetSpawnClient();
|
||||
remoteClientManager.GetBundleManager();
|
||||
remoteClientManager.GetNWebSpawnClient();
|
||||
std::shared_ptr<AppMgrServiceInner> owner;
|
||||
WindowFocusChangedListener windowFocusChangedListener(owner, handler);
|
||||
sptr<Rosen::FocusChangeInfo> focusChangeInfo = nullptr;
|
||||
windowFocusChangedListener.OnFocused(focusChangeInfo);
|
||||
windowFocusChangedListener.OnUnfocused(focusChangeInfo);
|
||||
return (appSpawnClient.StartProcessImpl(startMsg, pid) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "appmgrrest_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "app_death_recipient.h"
|
||||
#include "app_mgr_service_event_handler.h"
|
||||
#include "app_process_manager.h"
|
||||
#define private public
|
||||
#include "app_spawn_client.h"
|
||||
#include "app_spawn_msg_wrapper.h"
|
||||
#undef private
|
||||
#include "app_spawn_socket.h"
|
||||
#include "remote_client_manager.h"
|
||||
#include "window_focus_changed_listener.h"
|
||||
#include "ability_record.h"
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
sptr<Token> GetFuzzAbilityToken()
|
||||
{
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
|
||||
abilityRequest.abilityInfo.name = "MainAbility";
|
||||
abilityRequest.abilityInfo.type = AbilityType::PAGE;
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (abilityRecord) {
|
||||
token = abilityRecord->GetToken();
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
sptr<AppDeathRecipient> appDeathRecipient = new AppDeathRecipient();
|
||||
wptr<IRemoteObject> remote;
|
||||
appDeathRecipient->OnRemoteDied(remote);
|
||||
std::shared_ptr<AMSEventHandler> handler;
|
||||
appDeathRecipient->SetEventHandler(handler);
|
||||
std::shared_ptr<AppMgrServiceInner> serviceInner;
|
||||
appDeathRecipient->SetAppMgrServiceInner(serviceInner);
|
||||
bool isRenderProcess = *data % ENABLE;
|
||||
appDeathRecipient->SetIsRenderProcess(isRenderProcess);
|
||||
AppProcessManager appProcessManager;
|
||||
std::shared_ptr<AppTaskInfo> appTaskInfo;
|
||||
appProcessManager.RemoveAppFromRecentList(appTaskInfo);
|
||||
std::string appName(data, size);
|
||||
std::string processName(data, size);
|
||||
pid_t pid = static_cast<pid_t>(GetU32Data(data));
|
||||
int32_t recordId = static_cast<int32_t>(GetU32Data(data));
|
||||
appProcessManager.AddAppToRecentList(appName, processName, pid, recordId);
|
||||
appProcessManager.PushAppFront(recordId);
|
||||
appProcessManager.GetAppTaskInfoById(recordId);
|
||||
std::string bundleName(data, size);
|
||||
appProcessManager.GetAppTaskInfoByProcessName(appName, bundleName);
|
||||
appProcessManager.GetRecentAppList();
|
||||
appProcessManager.RemoveAppFromRecentListById(recordId);
|
||||
appProcessManager.ClearRecentAppList();
|
||||
AppSpawnClient appSpawnClient;
|
||||
appSpawnClient.OpenConnection();
|
||||
std::shared_ptr<AppSpawnSocket> socket;
|
||||
appSpawnClient.SetSocket(socket);
|
||||
appSpawnClient.PreStartNWebSpawnProcess();
|
||||
appSpawnClient.PreStartNWebSpawnProcessImpl();
|
||||
AppSpawnStartMsg startMsg;
|
||||
appSpawnClient.StartProcess(startMsg, pid);
|
||||
int status = static_cast<int>(GetU32Data(data));
|
||||
appSpawnClient.GetRenderProcessTerminationStatus(startMsg, status);
|
||||
appSpawnClient.QueryConnectionState();
|
||||
appSpawnClient.CloseConnection();
|
||||
AppSpawnMsgWrapper appSpawnMsgWrapper;
|
||||
appSpawnMsgWrapper.AssembleMsg(startMsg);
|
||||
appSpawnMsgWrapper.VerifyMsg(startMsg);
|
||||
appSpawnMsgWrapper.DumpMsg();
|
||||
appSpawnMsgWrapper.FreeMsg();
|
||||
AppSpawnSocket appSpawnSocket;
|
||||
std::shared_ptr<OHOS::AppSpawn::ClientSocket> clientSocket;
|
||||
appSpawnSocket.SetClientSocket(clientSocket);
|
||||
appSpawnSocket.OpenAppSpawnConnection();
|
||||
int32_t len = appSpawnMsgWrapper.GetMsgLength();
|
||||
appSpawnSocket.WriteMessage(appSpawnMsgWrapper.GetMsgBuf(), len);
|
||||
appSpawnSocket.ReadMessage(reinterpret_cast<void *>(*data), len);
|
||||
appSpawnSocket.CloseAppSpawnConnection();
|
||||
RemoteClientManager remoteClientManager;
|
||||
sptr<IBundleMgr> bundleManager = nullptr;
|
||||
remoteClientManager.SetBundleManager(bundleManager);
|
||||
std::shared_ptr<AppSpawnClient> appSpawnClientptr;
|
||||
remoteClientManager.SetSpawnClient(appSpawnClientptr);
|
||||
remoteClientManager.GetSpawnClient();
|
||||
remoteClientManager.GetBundleManager();
|
||||
remoteClientManager.GetNWebSpawnClient();
|
||||
std::shared_ptr<AppMgrServiceInner> owner;
|
||||
WindowFocusChangedListener windowFocusChangedListener(owner, handler);
|
||||
sptr<Rosen::FocusChangeInfo> focusChangeInfo = nullptr;
|
||||
windowFocusChangedListener.OnFocused(focusChangeInfo);
|
||||
windowFocusChangedListener.OnUnfocused(focusChangeInfo);
|
||||
return (appSpawnClient.StartProcessImpl(startMsg, pid) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_APPMGRREST_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPMGRREST_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "appmgrrest_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPMGRREST_FUZZER_H
|
||||
/*
|
||||
* 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_APPMGRREST_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPMGRREST_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "appmgrrest_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPMGRREST_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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,111 +1,111 @@
|
||||
/*
|
||||
* 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 "appstateobservermanager_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "app_state_observer_manager.h"
|
||||
#undef private
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AppStateObserverManager> appStateObserverManager = std::make_shared<AppStateObserverManager>();
|
||||
sptr<IApplicationStateObserver> observer;
|
||||
std::vector<std::string> bundleNameList;
|
||||
appStateObserverManager->RegisterApplicationStateObserver(observer, bundleNameList);
|
||||
appStateObserverManager->UnregisterApplicationStateObserver(observer);
|
||||
appStateObserverManager->AddObserverDeathRecipient(observer);
|
||||
appStateObserverManager->RemoveObserverDeathRecipient(observer);
|
||||
std::shared_ptr<AppRunningRecord> appRecord;
|
||||
|
||||
appStateObserverManager->HandleOnAppProcessCreated(appRecord);
|
||||
ApplicationState state = ApplicationState::APP_STATE_CREATE;
|
||||
bool needNotifyApp = *data % ENABLE;
|
||||
appStateObserverManager->HandleAppStateChanged(appRecord, state, needNotifyApp);
|
||||
appStateObserverManager->HandleOnAppProcessDied(appRecord);
|
||||
|
||||
std::shared_ptr<RenderRecord> renderRecord;
|
||||
appStateObserverManager->HandleOnRenderProcessCreated(renderRecord);
|
||||
appStateObserverManager->HandleOnRenderProcessDied(renderRecord);
|
||||
|
||||
ProcessData processData;
|
||||
appStateObserverManager->HandleOnProcessCreated(processData);
|
||||
appStateObserverManager->HandleOnProcessStateChanged(appRecord);
|
||||
appStateObserverManager->HandleOnProcessDied(processData);
|
||||
AbilityStateData abilityStateData;
|
||||
bool isAbility = *data % ENABLE;
|
||||
|
||||
appStateObserverManager->HandleStateChangedNotifyObserver(abilityStateData, isAbility);
|
||||
|
||||
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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "appstateobservermanager_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define private public
|
||||
#include "app_state_observer_manager.h"
|
||||
#undef private
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
constexpr uint8_t ENABLE = 2;
|
||||
constexpr size_t OFFSET_ZERO = 24;
|
||||
constexpr size_t OFFSET_ONE = 16;
|
||||
constexpr size_t OFFSET_TWO = 8;
|
||||
}
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << OFFSET_ZERO) | (ptr[1] << OFFSET_ONE) | (ptr[2] << OFFSET_TWO) | ptr[3];
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<AppStateObserverManager> appStateObserverManager = std::make_shared<AppStateObserverManager>();
|
||||
sptr<IApplicationStateObserver> observer;
|
||||
std::vector<std::string> bundleNameList;
|
||||
appStateObserverManager->RegisterApplicationStateObserver(observer, bundleNameList);
|
||||
appStateObserverManager->UnregisterApplicationStateObserver(observer);
|
||||
appStateObserverManager->AddObserverDeathRecipient(observer);
|
||||
appStateObserverManager->RemoveObserverDeathRecipient(observer);
|
||||
std::shared_ptr<AppRunningRecord> appRecord;
|
||||
|
||||
appStateObserverManager->HandleOnAppProcessCreated(appRecord);
|
||||
ApplicationState state = ApplicationState::APP_STATE_CREATE;
|
||||
bool needNotifyApp = *data % ENABLE;
|
||||
appStateObserverManager->HandleAppStateChanged(appRecord, state, needNotifyApp);
|
||||
appStateObserverManager->HandleOnAppProcessDied(appRecord);
|
||||
|
||||
std::shared_ptr<RenderRecord> renderRecord;
|
||||
appStateObserverManager->HandleOnRenderProcessCreated(renderRecord);
|
||||
appStateObserverManager->HandleOnRenderProcessDied(renderRecord);
|
||||
|
||||
ProcessData processData;
|
||||
appStateObserverManager->HandleOnProcessCreated(processData);
|
||||
appStateObserverManager->HandleOnProcessStateChanged(appRecord);
|
||||
appStateObserverManager->HandleOnProcessDied(processData);
|
||||
AbilityStateData abilityStateData;
|
||||
bool isAbility = *data % ENABLE;
|
||||
|
||||
appStateObserverManager->HandleStateChangedNotifyObserver(abilityStateData, isAbility);
|
||||
|
||||
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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "appstateobservermanager_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
/*
|
||||
* 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_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "appstateobservermanager_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_APPSTATEOBSERVERMANAGER_FUZZER_H
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
|
||||
@@ -1,80 +1,80 @@
|
||||
/*
|
||||
* 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 "blockamsservice_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "ability_record.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
auto abilitymgr = AbilityManagerClient::GetInstance();
|
||||
if (!abilitymgr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilitymgr->BlockAmsService() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "blockamsservice_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "ability_record.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
auto abilitymgr = AbilityManagerClient::GetInstance();
|
||||
if (!abilitymgr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilitymgr->BlockAmsService() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_BLOCKAMSSERVICE_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_BLOCKAMSSERVICE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "blockamsservice_fuzzer"
|
||||
|
||||
#endif
|
||||
/*
|
||||
* 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_BLOCKAMSSERVICE_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_BLOCKAMSSERVICE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "blockamsservice_fuzzer"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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,87 +1,87 @@
|
||||
/*
|
||||
* 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 "cancelwantsender_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "securec.h"
|
||||
#include "parcel.h"
|
||||
#include "sender_info.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
auto abilitymgr = AbilityManagerClient::GetInstance();
|
||||
if (!abilitymgr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Parcel parcel;
|
||||
sptr<IWantSender> sender = nullptr;
|
||||
if (parcel.WriteBuffer(data, size)) {
|
||||
sender = iface_cast<AAFwk::IWantSender>((static_cast<MessageParcel*>(&parcel))->ReadRemoteObject());
|
||||
}
|
||||
if (sender) {
|
||||
abilitymgr->CancelWantSender(sender);
|
||||
}
|
||||
|
||||
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 = (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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 "cancelwantsender_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "securec.h"
|
||||
#include "parcel.h"
|
||||
#include "sender_info.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
auto abilitymgr = AbilityManagerClient::GetInstance();
|
||||
if (!abilitymgr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Parcel parcel;
|
||||
sptr<IWantSender> sender = nullptr;
|
||||
if (parcel.WriteBuffer(data, size)) {
|
||||
sender = iface_cast<AAFwk::IWantSender>((static_cast<MessageParcel*>(&parcel))->ReadRemoteObject());
|
||||
}
|
||||
if (sender) {
|
||||
abilitymgr->CancelWantSender(sender);
|
||||
}
|
||||
|
||||
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 = (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 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_CANCELWANTSENDER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_CANCELWANTSENDER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cancelwantsender_fuzzer"
|
||||
|
||||
#endif
|
||||
/*
|
||||
* 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_CANCELWANTSENDER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_CANCELWANTSENDER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cancelwantsender_fuzzer"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 +1,25 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
Reference in New Issue
Block a user