diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index e5543f464..f83e96dd1 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -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", diff --git a/test/fuzztest/devicestatusstub_fuzzer/BUILD.gn b/test/fuzztest/devicestatusstub_fuzzer/BUILD.gn deleted file mode 100644 index 336643f31..000000000 --- a/test/fuzztest/devicestatusstub_fuzzer/BUILD.gn +++ /dev/null @@ -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" ] -} diff --git a/test/fuzztest/devicestatusstub_fuzzer/corpus/init b/test/fuzztest/devicestatusstub_fuzzer/corpus/init deleted file mode 100644 index e4ceac1bc..000000000 --- a/test/fuzztest/devicestatusstub_fuzzer/corpus/init +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.cpp b/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.cpp deleted file mode 100644 index 8e94e42c5..000000000 --- a/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.cpp +++ /dev/null @@ -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 -#include - -#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::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(data); - OHOS::DeviceStatusStubFuzzTest(ch, size); - return 0; -} - diff --git a/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.h b/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.h deleted file mode 100644 index d6d31a33f..000000000 --- a/test/fuzztest/devicestatusstub_fuzzer/devicestatusstub_fuzzer.h +++ /dev/null @@ -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 diff --git a/test/fuzztest/devicestatusstub_fuzzer/project.xml b/test/fuzztest/devicestatusstub_fuzzer/project.xml deleted file mode 100644 index 4fdbc407f..000000000 --- a/test/fuzztest/devicestatusstub_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - -