mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-23 23:50:23 +00:00
commit
f8f1deb439
@ -22,7 +22,6 @@ group("device_status_fuzztest") {
|
||||
"devicegetcachestub_fuzzer:fuzztest",
|
||||
"devicestatusagent_fuzzer:fuzztest",
|
||||
"devicestatusclient_fuzzer:fuzztest",
|
||||
"devicestatusstub_fuzzer:fuzztest",
|
||||
"devicesubscribestub_fuzzer:fuzztest",
|
||||
"deviceunsubscribestub_fuzzer:fuzztest",
|
||||
"getdragtargetpid_fuzzer:fuzztest",
|
||||
|
@ -1,82 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//base/msdp/device_status/device_status.gni")
|
||||
if (fusion_interaction_coordination) {
|
||||
import("//base/msdp/motion/motion.gni")
|
||||
}
|
||||
|
||||
###############################hydra_fuzz#################################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
module_output_path = "${device_status_fuzz_output_path}"
|
||||
deps_ex = [
|
||||
"distributed_input:libdinput_sdk",
|
||||
"device_manager:devicemanagersdk",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"graphic_2d:libcomposer",
|
||||
"graphic_2d:window_animation",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
###############################fuzztest#################################
|
||||
ohos_fuzztest("DevicestatusstubFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file =
|
||||
"${device_status_root_path}/test/fuzztest/devicestatusstub_fuzzer"
|
||||
include_dirs = [
|
||||
"${device_status_root_path}/libs/interface",
|
||||
"${device_status_service_path}/interaction/drag/include",
|
||||
"${device_status_service_path}/interaction/coordination/include",
|
||||
"${device_status_service_path}/communication/service/include",
|
||||
"${device_status_utils_path}/include",
|
||||
"//third_party/cJSON",
|
||||
]
|
||||
|
||||
if (defined(fusion_interaction_motion_drag) &&
|
||||
fusion_interaction_motion_drag) {
|
||||
include_dirs += [ "${motion_service_path}/native/include" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "devicestatusstub_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${device_status_interfaces_path}/innerkits:devicestatus_client",
|
||||
"${device_status_root_path}/services:devicestatus_static_service",
|
||||
"${device_status_root_path}/utils/ipc:devicestatus_ipc",
|
||||
"${device_status_utils_path}:devicestatus_util",
|
||||
]
|
||||
|
||||
external_deps = deps_ex
|
||||
|
||||
if (defined(fusion_interaction_motion_drag) &&
|
||||
fusion_interaction_motion_drag) {
|
||||
external_deps += [ "motion:motion_drag" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":DevicestatusstubFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "devicestatusstub_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "securec.h"
|
||||
#include "singleton.h"
|
||||
|
||||
#define private public
|
||||
#include "devicestatus_service.h"
|
||||
#include "message_parcel.h"
|
||||
|
||||
using namespace OHOS::Msdp::DeviceStatus;
|
||||
|
||||
namespace OHOS {
|
||||
constexpr size_t FOO_MAX_LEN { 1024 };
|
||||
constexpr size_t MIN_SIZE { 4 };
|
||||
const std::u16string FORMMGR_DEVICE_TOKEN { u"ohos.msdp.Idevicestatus" };
|
||||
|
||||
uint32_t GetU32Data(const char* ch, size_t size)
|
||||
{
|
||||
if (ch == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (size < MIN_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
// 将第0个数字左移24位,将第1个数字左移16位,将第2个数字左移8位,第3个数字不左移
|
||||
return (ch[0] << 24) | (ch[1] << 16) | (ch[2] << 8) | (ch[3]);
|
||||
}
|
||||
|
||||
bool DeviceStatusStubFuzzTest(const char* data, size_t size)
|
||||
{
|
||||
uint32_t code = GetU32Data(data, size);
|
||||
MessageParcel datas;
|
||||
datas.WriteInterfaceToken(FORMMGR_DEVICE_TOKEN);
|
||||
datas.WriteBuffer(data, size);
|
||||
datas.RewindRead(0);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
DelayedSingleton<DeviceStatusService>::GetInstance()->OnRemoteRequest(code, datas, reply, option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
if (data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate the length of size */
|
||||
if ((size < OHOS::MIN_SIZE) || (size > OHOS::FOO_MAX_LEN)) {
|
||||
return 0;
|
||||
}
|
||||
const char* ch = reinterpret_cast<const char*>(data);
|
||||
OHOS::DeviceStatusStubFuzzTest(ch, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DEVICESTATUSSTUB_FUZZER_H
|
||||
#define DEVICESTATUSSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "devicestatusstub_fuzzer"
|
||||
|
||||
#endif // DEVICESTATUSSTUB_FUZZER_H
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user