From 96327f0754586a2fe1c095428d15bfdfe8bbee74 Mon Sep 17 00:00:00 2001 From: litiangang4 Date: Fri, 2 Jun 2023 17:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9fuzz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: litiangang4 --- test/fuzztest/BUILD.gn | 8 +- .../BUILD.gn | 11 ++- .../corpus/init | 0 .../dinputconfigdh_fuzzer.cpp} | 44 +--------- .../dinputconfigdh_fuzzer.h} | 8 +- .../project.xml | 0 test/fuzztest/dinputinitsink_fuzzer/BUILD.gn | 83 +++++++++++++++++++ .../corpus/init | 0 .../dinputinitsink_fuzzer.cpp | 51 ++++++++++++ .../dinputinitsink_fuzzer.h | 22 +++++ .../project.xml | 0 .../fuzztest/dinputinitsource_fuzzer/BUILD.gn | 83 +++++++++++++++++++ .../dinputinitsource_fuzzer/corpus/init | 14 ++++ .../dinputinitsource_fuzzer.cpp | 51 ++++++++++++ .../dinputinitsource_fuzzer.h | 22 +++++ .../dinputinitsource_fuzzer/project.xml | 25 ++++++ .../BUILD.gn | 11 ++- .../dinputreleasesink_fuzzer/corpus/init | 14 ++++ .../dinputreleasesink_fuzzer.cpp | 49 +++++++++++ .../dinputreleasesink_fuzzer.h} | 6 +- .../dinputreleasesink_fuzzer/project.xml | 25 ++++++ .../dinputreleasesource_fuzzer/BUILD.gn | 83 +++++++++++++++++++ .../dinputreleasesource_fuzzer/corpus/init | 14 ++++ .../dinputreleasesource_fuzzer.cpp | 49 +++++++++++ .../dinputreleasesource_fuzzer.h | 22 +++++ .../dinputreleasesource_fuzzer/project.xml | 25 ++++++ .../dinputsubscribelocaldh_fuzzer/BUILD.gn | 83 +++++++++++++++++++ .../dinputsubscribelocaldh_fuzzer/corpus/init | 14 ++++ .../dinputsubscribelocaldh_fuzzer.cpp} | 30 +------ .../dinputsubscribelocaldh_fuzzer.h | 22 +++++ .../dinputsubscribelocaldh_fuzzer/project.xml | 25 ++++++ 31 files changed, 801 insertions(+), 93 deletions(-) rename test/fuzztest/{dinputsourcehandler_fuzzer => dinputconfigdh_fuzzer}/BUILD.gn (88%) rename test/fuzztest/{dinputsinkhandler_fuzzer => dinputconfigdh_fuzzer}/corpus/init (100%) rename test/fuzztest/{dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.cpp => dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.cpp} (54%) rename test/fuzztest/{dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.h => dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.h} (77%) rename test/fuzztest/{dinputsinkhandler_fuzzer => dinputconfigdh_fuzzer}/project.xml (100%) create mode 100644 test/fuzztest/dinputinitsink_fuzzer/BUILD.gn rename test/fuzztest/{dinputsourcehandler_fuzzer => dinputinitsink_fuzzer}/corpus/init (100%) create mode 100644 test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.cpp create mode 100644 test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.h rename test/fuzztest/{dinputsourcehandler_fuzzer => dinputinitsink_fuzzer}/project.xml (100%) create mode 100644 test/fuzztest/dinputinitsource_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dinputinitsource_fuzzer/corpus/init create mode 100644 test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.cpp create mode 100644 test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.h create mode 100644 test/fuzztest/dinputinitsource_fuzzer/project.xml rename test/fuzztest/{dinputsinkhandler_fuzzer => dinputreleasesink_fuzzer}/BUILD.gn (88%) create mode 100644 test/fuzztest/dinputreleasesink_fuzzer/corpus/init create mode 100644 test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.cpp rename test/fuzztest/{dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.h => dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.h} (85%) create mode 100644 test/fuzztest/dinputreleasesink_fuzzer/project.xml create mode 100644 test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dinputreleasesource_fuzzer/corpus/init create mode 100644 test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.cpp create mode 100644 test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.h create mode 100644 test/fuzztest/dinputreleasesource_fuzzer/project.xml create mode 100644 test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dinputsubscribelocaldh_fuzzer/corpus/init rename test/fuzztest/{dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.cpp => dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.cpp} (63%) create mode 100644 test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.h create mode 100644 test/fuzztest/dinputsubscribelocaldh_fuzzer/project.xml diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 09f319e..6b0b5e5 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -15,8 +15,12 @@ group("fuzztest") { testonly = true deps = [ - "dinputsinkhandler_fuzzer:fuzztest", - "dinputsourcehandler_fuzzer:fuzztest", + "dinputconfigdh_fuzzer:fuzztest", + "dinputinitsink_fuzzer:fuzztest", + "dinputinitsource_fuzzer:fuzztest", + "dinputreleasesink_fuzzer:fuzztest", + "dinputreleasesource_fuzzer:fuzztest", + "dinputsubscribelocaldh_fuzzer:fuzztest", "distributedinputclient_fuzzer:fuzztest", "distributedinputkit_fuzzer:fuzztest", "distributedinputsinktransport_fuzzer:fuzztest", diff --git a/test/fuzztest/dinputsourcehandler_fuzzer/BUILD.gn b/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn similarity index 88% rename from test/fuzztest/dinputsourcehandler_fuzzer/BUILD.gn rename to test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn index 76f3e60..9966ade 100644 --- a/test/fuzztest/dinputsourcehandler_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn @@ -17,11 +17,11 @@ import("//build/test.gni") import("../../../distributedinput.gni") ##############################fuzztest########################################## -ohos_fuzztest("DinputSourceHandlerFuzzTest") { +ohos_fuzztest("DinputConfigDhFuzzTest") { module_out_path = "distributed_input/system" fuzz_config_file = - "${distributedinput_path}/test/fuzztest/dinputsourcehandler_fuzzer" + "${distributedinput_path}/test/fuzztest/dinputconfigdh_fuzzer" include_dirs = [ "include", @@ -31,7 +31,6 @@ ohos_fuzztest("DinputSourceHandlerFuzzTest") { "${distributedinput_path}/services/sink/sinkmanager/include", "${distributedinput_path}/frameworks/include", "${distributedinput_path}/sourcehandler/include", - "${distributedinput_path}/sinkhandler/include", "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", "${common_path}/include", @@ -53,7 +52,7 @@ ohos_fuzztest("DinputSourceHandlerFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dinput_source_handler_fuzzer.cpp" ] + sources = [ "dinputconfigdh_fuzzer.cpp" ] deps = [ "${distributedinput_path}/sourcehandler:libdinput_source_handler", @@ -70,7 +69,7 @@ ohos_fuzztest("DinputSourceHandlerFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DinputSourceHandlerFuzzTest\"", + "DH_LOG_TAG=\"DinputConfigDhFuzzTest\"", "LOG_DOMAIN=0xD004100", ] } @@ -79,6 +78,6 @@ ohos_fuzztest("DinputSourceHandlerFuzzTest") { group("fuzztest") { testonly = true - deps = [ ":DinputSourceHandlerFuzzTest" ] + deps = [ ":DinputConfigDhFuzzTest" ] } ############################################################################### diff --git a/test/fuzztest/dinputsinkhandler_fuzzer/corpus/init b/test/fuzztest/dinputconfigdh_fuzzer/corpus/init similarity index 100% rename from test/fuzztest/dinputsinkhandler_fuzzer/corpus/init rename to test/fuzztest/dinputconfigdh_fuzzer/corpus/init diff --git a/test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.cpp b/test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.cpp similarity index 54% rename from test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.cpp rename to test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.cpp index c337640..fcf9cfb 100644 --- a/test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.cpp +++ b/test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "dinput_source_handler_fuzzer.h" +#include "dinputconfigdh_fuzzer.h" #include #include @@ -26,51 +26,11 @@ #include "constants_dinput.h" #include "distributed_input_handler.h" #include "distributed_input_kit.h" -#include "distributed_input_sink_handler.h" #include "distributed_input_source_handler.h" -#include "i_distributed_sink_input.h" #include "i_distributed_source_input.h" namespace OHOS { namespace DistributedHardware { -class TestRegisterInputCallback : public OHOS::DistributedHardware::RegisterCallback { -public: - TestRegisterInputCallback() = default; - virtual ~TestRegisterInputCallback() = default; - int32_t OnRegisterResult(const std::string &devId, const std::string &dhId, int32_t status, - const std::string &data) override - { - return 0; - } -}; - -class TestUnregisterInputCallback : public OHOS::DistributedHardware::UnregisterCallback { -public: - TestUnregisterInputCallback() = default; - virtual ~TestUnregisterInputCallback() = default; - int32_t OnUnregisterResult(const std::string &devId, const std::string &dhId, int32_t status, - const std::string &data) override - { - return 0; - } -}; - -void InitSourceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string params(reinterpret_cast(data), size); - DistributedInput::DistributedInputSourceHandler::GetInstance().InitSource(params); -} - -void ReleaseSourceFuzzTest(const uint8_t* data, size_t size) -{ - (void)data; - (void)size; - DistributedInput::DistributedInputSourceHandler::GetInstance().ReleaseSource(); -} - void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -89,8 +49,6 @@ void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::DistributedHardware::InitSourceFuzzTest(data, size); - OHOS::DistributedHardware::ReleaseSourceFuzzTest(data, size); OHOS::DistributedHardware::ConfigDistributedHardwareFuzzTest(data, size); return 0; } \ No newline at end of file diff --git a/test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.h b/test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.h similarity index 77% rename from test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.h rename to test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.h index dda0d85..3e9378c 100644 --- a/test/fuzztest/dinputsourcehandler_fuzzer/dinput_source_handler_fuzzer.h +++ b/test/fuzztest/dinputconfigdh_fuzzer/dinputconfigdh_fuzzer.h @@ -14,9 +14,9 @@ */ -#ifndef DINPUT_SOURCE_HANDLER_FUZZER_H -#define DINPUT_SOURCE_HANDLER_FUZZER_H +#ifndef DINPUT_CONFIG_DH_FUZZER_H +#define DINPUT_CONFIG_DH_FUZZER_H -#define FUZZ_PROJECT_NAME "dinputsourcehandler_fuzzer" +#define FUZZ_PROJECT_NAME "dinputconfigdh_fuzzer" -#endif // DINPUT_SOURCE_HANDLER_FUZZER_H \ No newline at end of file +#endif // DINPUT_CONFIG_DH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputsinkhandler_fuzzer/project.xml b/test/fuzztest/dinputconfigdh_fuzzer/project.xml similarity index 100% rename from test/fuzztest/dinputsinkhandler_fuzzer/project.xml rename to test/fuzztest/dinputconfigdh_fuzzer/project.xml diff --git a/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn b/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn new file mode 100644 index 0000000..a1148cd --- /dev/null +++ b/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../distributedinput.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DinputInitSinkFuzzTest") { + module_out_path = "distributed_input/system" + + fuzz_config_file = + "${distributedinput_path}/test/fuzztest/dinputinitsink_fuzzer" + + include_dirs = [ + "include", + "${distributedinput_path}/interfaces/inner_kits/include", + "${distributedinput_path}/interfaces/ipc/include", + "${distributedinput_path}/services/source/sourcemanager/include", + "${distributedinput_path}/services/sink/sinkmanager/include", + "${distributedinput_path}/frameworks/include", + "${distributedinput_path}/sinkhandler/include", + "${distributedinput_path}/inputdevicehandler/include", + "${service_common}/include", + "${common_path}/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "//third_party/json/include", + "${fwk_interfaces_path}/include", + "${fwk_interfaces_path}/include/ipc", + "${services_source_path}/inputinject/include", + "${utils_path}/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dinputinitsink_fuzzer.cpp" ] + + deps = [ + "${distributedinput_path}/sinkhandler:libdinput_sink_handler", + "//third_party/libevdev:libevdev", + ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ipc:ipc_core", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DinputInitSinkFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DinputInitSinkFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/dinputsourcehandler_fuzzer/corpus/init b/test/fuzztest/dinputinitsink_fuzzer/corpus/init similarity index 100% rename from test/fuzztest/dinputsourcehandler_fuzzer/corpus/init rename to test/fuzztest/dinputinitsink_fuzzer/corpus/init diff --git a/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.cpp b/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.cpp new file mode 100644 index 0000000..81a4b6b --- /dev/null +++ b/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * 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 "dinputinitsink_fuzzer.h" + +#include +#include +#include +#include +#include + +#include + +#include "constants_dinput.h" +#include "distributed_input_handler.h" +#include "distributed_input_kit.h" +#include "distributed_input_sink_handler.h" +#include "i_distributed_sink_input.h" + +namespace OHOS { +namespace DistributedHardware { +void InitSinkFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string params(reinterpret_cast(data), size); + DistributedInput::DistributedInputSinkHandler::GetInstance().InitSink(params); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::InitSinkFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.h b/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.h new file mode 100644 index 0000000..657a0d1 --- /dev/null +++ b/test/fuzztest/dinputinitsink_fuzzer/dinputinitsink_fuzzer.h @@ -0,0 +1,22 @@ +/* + * 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 DINPUT_INIT_SINK_FUZZER_H +#define DINPUT_INIT_SINK_FUZZER_H + +#define FUZZ_PROJECT_NAME "dinputreleasesink_fuzzer" + +#endif // DINPUT_INIT_SINK_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputsourcehandler_fuzzer/project.xml b/test/fuzztest/dinputinitsink_fuzzer/project.xml similarity index 100% rename from test/fuzztest/dinputsourcehandler_fuzzer/project.xml rename to test/fuzztest/dinputinitsink_fuzzer/project.xml diff --git a/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn b/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn new file mode 100644 index 0000000..fd97c13 --- /dev/null +++ b/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../distributedinput.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DinputInitSourceFuzzTest") { + module_out_path = "distributed_input/system" + + fuzz_config_file = + "${distributedinput_path}/test/fuzztest/dinputinitsource_fuzzer" + + include_dirs = [ + "include", + "${distributedinput_path}/interfaces/inner_kits/include", + "${distributedinput_path}/interfaces/ipc/include", + "${distributedinput_path}/services/source/sourcemanager/include", + "${distributedinput_path}/services/sink/sinkmanager/include", + "${distributedinput_path}/frameworks/include", + "${distributedinput_path}/sourcehandler/include", + "${distributedinput_path}/inputdevicehandler/include", + "${service_common}/include", + "${common_path}/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "//third_party/json/include", + "${fwk_interfaces_path}/include", + "${fwk_interfaces_path}/include/ipc", + "${services_source_path}/inputinject/include", + "${utils_path}/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dinputinitsource_fuzzer.cpp" ] + + deps = [ + "${distributedinput_path}/sourcehandler:libdinput_source_handler", + "//third_party/libevdev:libevdev", + ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ipc:ipc_core", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DinputInitSourceFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DinputInitSourceFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/dinputinitsource_fuzzer/corpus/init b/test/fuzztest/dinputinitsource_fuzzer/corpus/init new file mode 100644 index 0000000..e4ceac1 --- /dev/null +++ b/test/fuzztest/dinputinitsource_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/dinputinitsource_fuzzer/dinputinitsource_fuzzer.cpp b/test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.cpp new file mode 100644 index 0000000..a8489ab --- /dev/null +++ b/test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.cpp @@ -0,0 +1,51 @@ +/* + * 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 "dinputinitsource_fuzzer.h" + +#include +#include +#include +#include +#include + +#include + +#include "constants_dinput.h" +#include "distributed_input_handler.h" +#include "distributed_input_kit.h" +#include "distributed_input_source_handler.h" +#include "i_distributed_source_input.h" + +namespace OHOS { +namespace DistributedHardware { +void InitSourceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string params(reinterpret_cast(data), size); + DistributedInput::DistributedInputSourceHandler::GetInstance().InitSource(params); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::InitSourceFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.h b/test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.h new file mode 100644 index 0000000..9e28470 --- /dev/null +++ b/test/fuzztest/dinputinitsource_fuzzer/dinputinitsource_fuzzer.h @@ -0,0 +1,22 @@ +/* + * 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 DINPUT_INIT_SOURCE_FUZZER_H +#define DINPUT_INIT_SOURCE_FUZZER_H + +#define FUZZ_PROJECT_NAME "dinputinitsource_fuzzer" + +#endif // DINPUT_INIT_SOURCE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputinitsource_fuzzer/project.xml b/test/fuzztest/dinputinitsource_fuzzer/project.xml new file mode 100644 index 0000000..4fdbc40 --- /dev/null +++ b/test/fuzztest/dinputinitsource_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/dinputsinkhandler_fuzzer/BUILD.gn b/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn similarity index 88% rename from test/fuzztest/dinputsinkhandler_fuzzer/BUILD.gn rename to test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn index 908aaa1..825d94b 100644 --- a/test/fuzztest/dinputsinkhandler_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn @@ -17,11 +17,11 @@ import("//build/test.gni") import("../../../distributedinput.gni") ##############################fuzztest########################################## -ohos_fuzztest("DinputSinkHandlerFuzzTest") { +ohos_fuzztest("DinputReleaseSinkFuzzTest") { module_out_path = "distributed_input/system" fuzz_config_file = - "${distributedinput_path}/test/fuzztest/dinputsinkhandler_fuzzer" + "${distributedinput_path}/test/fuzztest/dinputreleasesink_fuzzer" include_dirs = [ "include", @@ -30,7 +30,6 @@ ohos_fuzztest("DinputSinkHandlerFuzzTest") { "${distributedinput_path}/services/source/sourcemanager/include", "${distributedinput_path}/services/sink/sinkmanager/include", "${distributedinput_path}/frameworks/include", - "${distributedinput_path}/sourcehandler/include", "${distributedinput_path}/sinkhandler/include", "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", @@ -53,7 +52,7 @@ ohos_fuzztest("DinputSinkHandlerFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dinput_sink_handler_fuzzer.cpp" ] + sources = [ "dinputreleasesink_fuzzer.cpp" ] deps = [ "${distributedinput_path}/sinkhandler:libdinput_sink_handler", @@ -70,7 +69,7 @@ ohos_fuzztest("DinputSinkHandlerFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DinputSinkHandlerFuzzTest\"", + "DH_LOG_TAG=\"DinputReleaseSinkFuzzTest\"", "LOG_DOMAIN=0xD004100", ] } @@ -79,6 +78,6 @@ ohos_fuzztest("DinputSinkHandlerFuzzTest") { group("fuzztest") { testonly = true - deps = [ ":DinputSinkHandlerFuzzTest" ] + deps = [ ":DinputReleaseSinkFuzzTest" ] } ############################################################################### diff --git a/test/fuzztest/dinputreleasesink_fuzzer/corpus/init b/test/fuzztest/dinputreleasesink_fuzzer/corpus/init new file mode 100644 index 0000000..e4ceac1 --- /dev/null +++ b/test/fuzztest/dinputreleasesink_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.cpp b/test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.cpp new file mode 100644 index 0000000..24500c9 --- /dev/null +++ b/test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "dinputreleasesink_fuzzer.h" + +#include +#include +#include +#include +#include + +#include + +#include "constants_dinput.h" +#include "distributed_input_handler.h" +#include "distributed_input_kit.h" +#include "distributed_input_sink_handler.h" +#include "i_distributed_sink_input.h" + +namespace OHOS { +namespace DistributedHardware { +void ReleaseSinkFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + DistributedInput::DistributedInputSinkHandler::GetInstance().ReleaseSink(); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ReleaseSinkFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.h b/test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.h similarity index 85% rename from test/fuzztest/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.h rename to test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.h index 5dd97ac..da96037 100644 --- a/test/fuzztest/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.h +++ b/test/fuzztest/dinputreleasesink_fuzzer/dinputreleasesink_fuzzer.h @@ -14,9 +14,9 @@ */ -#ifndef DINPUT_SINK_HANDLER_FUZZER_H -#define DINPUT_SINK_HANDLER_FUZZER_H +#ifndef DINPUT_RELEASE_SINK_FUZZER_H +#define DINPUT_RELEASE_SINK_FUZZER_H #define FUZZ_PROJECT_NAME "dinputsinkhandler_fuzzer" -#endif // DINPUT_SINK_HANDLER_FUZZER_H \ No newline at end of file +#endif // DINPUT_RELEASE_SINK_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputreleasesink_fuzzer/project.xml b/test/fuzztest/dinputreleasesink_fuzzer/project.xml new file mode 100644 index 0000000..4fdbc40 --- /dev/null +++ b/test/fuzztest/dinputreleasesink_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn b/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn new file mode 100644 index 0000000..5723ad6 --- /dev/null +++ b/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../distributedinput.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DinputReleaseSourceFuzzTest") { + module_out_path = "distributed_input/system" + + fuzz_config_file = + "${distributedinput_path}/test/fuzztest/dinputreleasesource_fuzzer" + + include_dirs = [ + "include", + "${distributedinput_path}/interfaces/inner_kits/include", + "${distributedinput_path}/interfaces/ipc/include", + "${distributedinput_path}/services/source/sourcemanager/include", + "${distributedinput_path}/services/sink/sinkmanager/include", + "${distributedinput_path}/frameworks/include", + "${distributedinput_path}/sourcehandler/include", + "${distributedinput_path}/inputdevicehandler/include", + "${service_common}/include", + "${common_path}/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "//third_party/json/include", + "${fwk_interfaces_path}/include", + "${fwk_interfaces_path}/include/ipc", + "${services_source_path}/inputinject/include", + "${utils_path}/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dinputreleasesource_fuzzer.cpp" ] + + deps = [ + "${distributedinput_path}/sourcehandler:libdinput_source_handler", + "//third_party/libevdev:libevdev", + ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ipc:ipc_core", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DinputReleaseSourceFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DinputReleaseSourceFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/dinputreleasesource_fuzzer/corpus/init b/test/fuzztest/dinputreleasesource_fuzzer/corpus/init new file mode 100644 index 0000000..e4ceac1 --- /dev/null +++ b/test/fuzztest/dinputreleasesource_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.cpp b/test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.cpp new file mode 100644 index 0000000..d5376fa --- /dev/null +++ b/test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * 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 "dinputreleasesource_fuzzer.h" + +#include +#include +#include +#include +#include + +#include + +#include "constants_dinput.h" +#include "distributed_input_handler.h" +#include "distributed_input_kit.h" +#include "distributed_input_source_handler.h" +#include "i_distributed_source_input.h" + +namespace OHOS { +namespace DistributedHardware { +void ReleaseSourceFuzzTest(const uint8_t* data, size_t size) +{ + (void)data; + (void)size; + DistributedInput::DistributedInputSourceHandler::GetInstance().ReleaseSource(); +} +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ReleaseSourceFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.h b/test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.h new file mode 100644 index 0000000..2309bf3 --- /dev/null +++ b/test/fuzztest/dinputreleasesource_fuzzer/dinputreleasesource_fuzzer.h @@ -0,0 +1,22 @@ +/* + * 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 DINPUT_RELEASE_SOURCE_FUZZER_H +#define DINPUT_RELEASE_SOURCE_FUZZER_H + +#define FUZZ_PROJECT_NAME "dinputreleasesource_fuzzer" + +#endif // DINPUT_RELEASE_SOURCE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputreleasesource_fuzzer/project.xml b/test/fuzztest/dinputreleasesource_fuzzer/project.xml new file mode 100644 index 0000000..4fdbc40 --- /dev/null +++ b/test/fuzztest/dinputreleasesource_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn b/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn new file mode 100644 index 0000000..b57d4f3 --- /dev/null +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../distributedinput.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DinputSubscribeLocalDhFuzzTest") { + module_out_path = "distributed_input/system" + + fuzz_config_file = + "${distributedinput_path}/test/fuzztest/dinputsubscribelocaldh_fuzzer" + + include_dirs = [ + "include", + "${distributedinput_path}/interfaces/inner_kits/include", + "${distributedinput_path}/interfaces/ipc/include", + "${distributedinput_path}/services/source/sourcemanager/include", + "${distributedinput_path}/services/sink/sinkmanager/include", + "${distributedinput_path}/frameworks/include", + "${distributedinput_path}/sinkhandler/include", + "${distributedinput_path}/inputdevicehandler/include", + "${service_common}/include", + "${common_path}/include", + "${fwk_common_path}/log/include", + "${fwk_common_path}/utils/include", + "${fwk_utils_path}/include/log", + "${fwk_utils_path}/include", + "//third_party/json/include", + "${fwk_interfaces_path}/include", + "${fwk_interfaces_path}/include/ipc", + "${services_source_path}/inputinject/include", + "${utils_path}/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dinputsubscribelocaldh_fuzzer.cpp" ] + + deps = [ + "${distributedinput_path}/sinkhandler:libdinput_sink_handler", + "//third_party/libevdev:libevdev", + ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ipc:ipc_core", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DinputSubscribeLocalDhFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DinputSubscribeLocalDhFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/dinputsubscribelocaldh_fuzzer/corpus/init b/test/fuzztest/dinputsubscribelocaldh_fuzzer/corpus/init new file mode 100644 index 0000000..e4ceac1 --- /dev/null +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.cpp b/test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.cpp similarity index 63% rename from test/fuzztest/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.cpp rename to test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.cpp index 2e66a6b..1f10ac3 100644 --- a/test/fuzztest/dinputsinkhandler_fuzzer/dinput_sink_handler_fuzzer.cpp +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "dinput_sink_handler_fuzzer.h" +#include "dinputsubscribelocaldh_fuzzer.h" #include #include @@ -27,28 +27,10 @@ #include "distributed_input_handler.h" #include "distributed_input_kit.h" #include "distributed_input_sink_handler.h" -#include "distributed_input_source_handler.h" #include "i_distributed_sink_input.h" -#include "i_distributed_source_input.h" namespace OHOS { namespace DistributedHardware { -void InitSinkFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string params(reinterpret_cast(data), size); - DistributedInput::DistributedInputSinkHandler::GetInstance().InitSink(params); -} - -void ReleaseSinkFuzzTest(const uint8_t* data, size_t size) -{ - (void)data; - (void)size; - DistributedInput::DistributedInputSinkHandler::GetInstance().ReleaseSink(); -} - void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -57,14 +39,7 @@ void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) std::string dhId(reinterpret_cast(data), size); std::string params(reinterpret_cast(data), size); DistributedInput::DistributedInputSinkHandler::GetInstance().SubscribeLocalHardware(dhId, params); -} -void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string dhId(reinterpret_cast(data), size); DistributedInput::DistributedInputSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); } } // namespace DistributedHardware @@ -74,9 +49,6 @@ void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ - OHOS::DistributedHardware::InitSinkFuzzTest(data, size); - OHOS::DistributedHardware::ReleaseSinkFuzzTest(data, size); OHOS::DistributedHardware::SubscribeLocalHardwareFuzzTest(data, size); - OHOS::DistributedHardware::UnsubscribeLocalHardwareFuzzTest(data, size); return 0; } \ No newline at end of file diff --git a/test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.h b/test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.h new file mode 100644 index 0000000..6b9c838 --- /dev/null +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/dinputsubscribelocaldh_fuzzer.h @@ -0,0 +1,22 @@ +/* + * 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 DINPUT_SUBSCRIBE_LOCAL_DH_FUZZER_H +#define DINPUT_SUBSCRIBE_LOCAL_DH_FUZZER_H + +#define FUZZ_PROJECT_NAME "dinputsubscribelocaldh_fuzzer" + +#endif // DINPUT_SUBSCRIBE_LOCAL_DH_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/dinputsubscribelocaldh_fuzzer/project.xml b/test/fuzztest/dinputsubscribelocaldh_fuzzer/project.xml new file mode 100644 index 0000000..4fdbc40 --- /dev/null +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + -- Gitee