From 9a66bcc683693f45839f1ddc6cb2d7cce56c37f6 Mon Sep 17 00:00:00 2001 From: qinlong0101 Date: Mon, 11 Jul 2022 16:28:31 +0800 Subject: [PATCH] modify screen FuzzTest Signed-off-by: qinlong0101 --- bundle.json | 4 +- .../native_cpp/test/fuzztest/BUILD.gn | 14 ++- .../BUILD.gn | 76 +++++++++++++++ .../configdistributedhardware_fuzzer.cpp | 47 +++++++++ .../configdistributedhardware_fuzzer.h} | 6 +- .../corpus/init | 0 .../project.xml | 0 .../handlerinitsource_fuzzer}/BUILD.gn | 10 +- .../handlerinitsource_fuzzer}/corpus/init | 0 .../initsource_fuzzer.cpp | 44 +++++++++ .../initsource_fuzzer.h | 6 +- .../handlerinitsource_fuzzer}/project.xml | 0 .../BUILD.gn | 21 ++-- .../corpus/init | 0 .../onremotesourcesvrdied_fuzzer.cpp | 39 ++++---- .../onremotesourcesvrdied_fuzzer.h} | 6 +- .../project.xml | 0 .../BUILD.gn | 76 +++++++++++++++ .../corpus/init | 0 .../project.xml | 0 .../registerdistributedhardware_fuzzer.cpp | 52 ++++++++++ .../registerdistributedhardware_fuzzer.h | 21 ++++ .../BUILD.gn | 76 +++++++++++++++ .../corpus/init | 0 .../project.xml | 0 .../unregisterdistributedhardware_fuzzer.cpp | 47 +++++++++ .../unregisterdistributedhardware_fuzzer.h | 21 ++++ .../BUILD.gn | 76 +++++++++++++++ .../configdistributedhardware_fuzzer.cpp} | 26 +---- .../configdistributedhardware_fuzzer.h | 21 ++++ .../corpus/init | 0 .../project.xml | 0 .../proxydscreennotify_fuzzer}/BUILD.gn | 21 ++-- .../proxydscreennotify_fuzzer}/corpus/init | 0 .../dscreennotify_fuzzer.cpp} | 26 ++--- .../dscreennotify_fuzzer.h | 6 +- .../proxydscreennotify_fuzzer}/project.xml | 0 .../proxyinitsource_fuzzer}/BUILD.gn | 10 +- .../proxyinitsource_fuzzer}/corpus/init | 0 .../initsource_fuzzer.cpp} | 38 +++++--- .../initsource_fuzzer.h} | 6 +- .../proxyinitsource_fuzzer}/project.xml | 0 .../BUILD.gn | 76 +++++++++++++++ .../corpus/init | 0 .../project.xml | 0 .../registerdistributedhardware_fuzzer.cpp} | 41 ++++---- .../registerdistributedhardware_fuzzer.h | 21 ++++ .../BUILD.gn | 76 +++++++++++++++ .../corpus/init | 0 .../project.xml | 0 .../unregisterdistributedhardware_fuzzer.cpp | 63 ++++++++++++ .../unregisterdistributedhardware_fuzzer.h | 21 ++++ screenhandler/test/fuzztest/BUILD.gn | 6 +- .../BUILD.gn | 10 +- .../corpus/init | 0 .../pluginhardware_fuzzer.cpp | 46 +++++++++ .../pluginhardware_fuzzer.h | 6 +- .../pluginhardware_fuzzer}/project.xml | 2 +- .../registerpluginlistener_fuzzer/BUILD.gn | 76 +++++++++++++++ .../registerpluginlistener_fuzzer/corpus/init | 16 ++++ .../registerpluginlistener_fuzzer/project.xml | 25 +++++ .../registerpluginlistener_fuzzer.cpp} | 19 +--- .../registerpluginlistener_fuzzer.h | 6 +- .../fuzztest/unpluginhardware_fuzzer/BUILD.gn | 76 +++++++++++++++ .../unpluginhardware_fuzzer/corpus/init | 16 ++++ .../unpluginhardware_fuzzer/project.xml | 25 +++++ .../unpluginhardware_fuzzer.cpp | 45 +++++++++ .../unpluginhardware_fuzzer.h | 21 ++++ .../screentransport/test/fuzztest/BUILD.gn | 24 ----- .../screendatachannel_fuzzer/BUILD.gn | 84 ---------------- .../screensinkprocessor_fuzzer/BUILD.gn | 82 ---------------- .../screen_sink_processor_fuzzer.cpp | 65 ------------- .../screen_sink_processor_fuzzer.h | 21 ---- .../fuzztest/screensinktrans_fuzzer/BUILD.gn | 84 ---------------- .../screen_sink_trans_fuzzer.cpp | 69 -------------- .../screensourceprocessor_fuzzer/BUILD.gn | 83 ---------------- .../screen_source_processor_fuzzer.cpp | 59 ------------ .../screen_source_processor_fuzzer.h | 21 ---- .../screensourcetrans_fuzzer/BUILD.gn | 95 ------------------- .../screen_source_trans_fuzzer.cpp | 68 ------------- .../screen_source_trans_fuzzer.h | 21 ---- .../softbusadapter/test/fuzztest/BUILD.gn | 18 ---- .../fuzztest/softbusadapter_fuzzer/BUILD.gn | 82 ---------------- .../softbus_adapter_fuzzer.cpp | 76 --------------- .../softbus_adapter_fuzzer.h | 21 ---- 85 files changed, 1319 insertions(+), 1143 deletions(-) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.h => dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h} (80%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkhandler_fuzzer => dscreen_source_handler/handlerconfigdistributedhardware_fuzzer}/corpus/init (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkhandler_fuzzer => dscreen_source_handler/handlerconfigdistributedhardware_fuzzer}/project.xml (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourcehandler_fuzzer => dscreen_source_handler/handlerinitsource_fuzzer}/BUILD.gn (90%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkproxy_fuzzer => dscreen_source_handler/handlerinitsource_fuzzer}/corpus/init (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp rename screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.h => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.h (84%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkproxy_fuzzer => dscreen_source_handler/handlerinitsource_fuzzer}/project.xml (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkproxy_fuzzer => dscreen_source_handler/handleronremotesourcesvrdied_fuzzer}/BUILD.gn (66%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourcehandler_fuzzer => dscreen_source_handler/handleronremotesourcesvrdied_fuzzer}/corpus/init (100%) rename services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp (50%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h => dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.h} (82%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourcehandler_fuzzer => dscreen_source_handler/handleronremotesourcesvrdied_fuzzer}/project.xml (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourceproxy_fuzzer => dscreen_source_handler/handlerregisterdistributedhardware_fuzzer}/corpus/init (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourceproxy_fuzzer => dscreen_source_handler/handlerregisterdistributedhardware_fuzzer}/project.xml (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn rename {services/screentransport/test/fuzztest/screendatachannel_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer}/corpus/init (100%) rename {screenhandler/test/fuzztest/dscreenhandler_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer}/project.xml (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp => dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp} (63%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h rename {services/screentransport/test/fuzztest/screensinkprocessor_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer}/corpus/init (100%) rename {services/screentransport/test/fuzztest/screensinkprocessor_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer}/project.xml (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkhandler_fuzzer => dscreen_source_proxy/proxydscreennotify_fuzzer}/BUILD.gn (68%) rename {services/screentransport/test/fuzztest/screensinktrans_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer}/corpus/init (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp => dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp} (62%) rename services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.h (83%) rename {services/screentransport/test/fuzztest/screensinktrans_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer}/project.xml (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourceproxy_fuzzer => dscreen_source_proxy/proxyinitsource_fuzzer}/BUILD.gn (91%) rename {services/screentransport/test/fuzztest/screensourceprocessor_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer}/corpus/init (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.cpp => dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp} (62%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.h => dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.h} (83%) rename {services/screentransport/test/fuzztest/screensourceprocessor_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer}/project.xml (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn rename {services/screentransport/test/fuzztest/screensourcetrans_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer}/corpus/init (100%) rename {services/screentransport/test/fuzztest/screensourcetrans_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer}/project.xml (100%) rename interfaces/innerkits/native_cpp/test/fuzztest/{dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.cpp => dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp} (52%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn rename {services/softbusadapter/test/fuzztest/softbusadapter_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer}/corpus/init (100%) rename {services/softbusadapter/test/fuzztest/softbusadapter_fuzzer => interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer}/project.xml (100%) create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp create mode 100644 interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h rename screenhandler/test/fuzztest/{dscreenhandler_fuzzer => pluginhardware_fuzzer}/BUILD.gn (92%) rename screenhandler/test/fuzztest/{dscreenhandler_fuzzer => pluginhardware_fuzzer}/corpus/init (100%) create mode 100644 screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp rename services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h => screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.h (82%) rename {services/screentransport/test/fuzztest/screendatachannel_fuzzer => screenhandler/test/fuzztest/pluginhardware_fuzzer}/project.xml (98%) create mode 100644 screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn create mode 100644 screenhandler/test/fuzztest/registerpluginlistener_fuzzer/corpus/init create mode 100644 screenhandler/test/fuzztest/registerpluginlistener_fuzzer/project.xml rename screenhandler/test/fuzztest/{dscreenhandler_fuzzer/dscreen_handler_fuzzer.cpp => registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp} (59%) rename interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.h => screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.h (81%) create mode 100644 screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn create mode 100644 screenhandler/test/fuzztest/unpluginhardware_fuzzer/corpus/init create mode 100644 screenhandler/test/fuzztest/unpluginhardware_fuzzer/project.xml create mode 100644 screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp create mode 100644 screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.h delete mode 100644 services/screentransport/test/fuzztest/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h delete mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h delete mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn delete mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp delete mode 100644 services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h delete mode 100644 services/softbusadapter/test/fuzztest/BUILD.gn delete mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn delete mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp delete mode 100644 services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h diff --git a/bundle.json b/bundle.json index 6504186d..fb4934f1 100644 --- a/bundle.json +++ b/bundle.json @@ -87,9 +87,7 @@ "//foundation/distributedhardware/distributed_screen/services/common/test/unittest:service_common_test", "//foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/test/unittest:screen_interface_test", "//foundation/distributedhardware/distributed_screen/screenhandler/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributed_screen/services/softbusadapter/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributed_screen/services/screentransport/test/fuzztest:fuzztest" + "//foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest" ] } } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn index da1ed29f..a8229e8e 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/BUILD.gn @@ -15,9 +15,15 @@ group("fuzztest") { testonly = true deps = [ - "dscreensinkhandler_fuzzer:fuzztest", - "dscreensinkproxy_fuzzer:fuzztest", - "dscreensourcehandler_fuzzer:fuzztest", - "dscreensourceproxy_fuzzer:fuzztest", + "dscreen_source_handler/handlerconfigdistributedhardware_fuzzer:fuzztest", + "dscreen_source_handler/handlerinitsource_fuzzer:fuzztest", + "dscreen_source_handler/handleronremotesourcesvrdied_fuzzer:fuzztest", + "dscreen_source_handler/handlerregisterdistributedhardware_fuzzer:fuzztest", + "dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer:fuzztest", + "dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer:fuzztest", + "dscreen_source_proxy/proxydscreennotify_fuzzer:fuzztest", + "dscreen_source_proxy/proxyinitsource_fuzzer:fuzztest", + "dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer:fuzztest", + "dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer:fuzztest", ] } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..ed8df58f --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("HandlerConfigDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourcehandler" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "configdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"HandlerConfigDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":HandlerConfigDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp new file mode 100644 index 00000000..cf1238d0 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "configdistributedhardware_fuzzer.h" + +#include +#include + +#include "dscreen_source_handler.h" + +namespace OHOS { +namespace DistributedHardware { +void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string key(reinterpret_cast(data), size); + std::string value(reinterpret_cast(data), size); + + DScreenSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ConfigDistributedHardwareFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h similarity index 80% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.h rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h index 2d109e76..c9f1c3d0 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef DSCREEN_SINK_HANDLER_FUZZER_H -#define DSCREEN_SINK_HANDLER_FUZZER_H +#ifndef CONFIGDISTRIBUTEDHARDWARE_FUZZER_H +#define CONFIGDISTRIBUTEDHARDWARE_FUZZER_H -#define FUZZ_PROJECT_NAME "dscreen_sink_handler_fuzzer" +#define FUZZ_PROJECT_NAME "configdistributedhardware_fuzzer" #endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/corpus/init similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/corpus/init diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/project.xml similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn similarity index 90% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn index b04d3990..12ce376d 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn @@ -18,10 +18,10 @@ import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("DscreenSourceHandlerFuzzTest") { +ohos_fuzztest("HandlerInitSourceFuzzTest") { module_out_path = "distributed_screen/dscreensourcehandler" - fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer" + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer" include_dirs = [ "//utils/system/safwk/native/include", @@ -45,7 +45,7 @@ ohos_fuzztest("DscreenSourceHandlerFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dscreen_source_handler_fuzzer.cpp" ] + sources = [ "initsource_fuzzer.cpp" ] deps = [ "${common_path}:distributed_screen_utils", @@ -56,7 +56,7 @@ ohos_fuzztest("DscreenSourceHandlerFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenSourceHandlerFuzzTest\"", + "DH_LOG_TAG=\"HandlerInitSourceFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -71,6 +71,6 @@ ohos_fuzztest("DscreenSourceHandlerFuzzTest") { ############################################################################### group("fuzztest") { testonly = true - deps = [ ":DscreenSourceHandlerFuzzTest" ] + deps = [ ":HandlerInitSourceFuzzTest" ] } ############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/corpus/init similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/corpus/init diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp new file mode 100644 index 00000000..4d804239 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * 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 "initsource_fuzzer.h" + +#include +#include + +#include "dscreen_source_handler.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); + + DScreenSourceHandler::GetInstance().InitSource(params); +} +} +} + +/* 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/screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.h similarity index 84% rename from screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.h rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.h index 7ca6e15b..4cd4dbef 100644 --- a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/initsource_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef DSCREEN_HANDLER_FUZZER_H -#define DSCREEN_HANDLER_FUZZER_H +#ifndef INTTSOURCE_FUZZER_H +#define INTTSOURCE_FUZZER_H -#define FUZZ_PROJECT_NAME "dscreen_handler_fuzzer" +#define FUZZ_PROJECT_NAME "initsource_fuzzer" #endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/project.xml similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn similarity index 66% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn index eba246c7..8964d77f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn @@ -18,10 +18,10 @@ import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("DscreenSinkProxyFuzzTest") { - module_out_path = "distributed_screen/dscreensinkproxy" +ohos_fuzztest("HandlerOnRemoteSourceSvrDiedFuzzTest") { + module_out_path = "distributed_screen/dscreensourcehandler" - fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer" + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer" include_dirs = [ "//utils/system/safwk/native/include", @@ -30,8 +30,12 @@ ohos_fuzztest("DscreenSinkProxyFuzzTest") { include_dirs += [ "include", + "include/callback", "${common_path}/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", ] cflags = [ @@ -41,17 +45,18 @@ ohos_fuzztest("DscreenSinkProxyFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dscreen_sink_proxy_fuzzer.cpp" ] + sources = [ "onremotesourcesvrdied_fuzzer.cpp" ] deps = [ "${common_path}:distributed_screen_utils", - "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", "//utils/native/base:utils", ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenSinkProxyFuzzTest\"", + "DH_LOG_TAG=\"HandlerOnRemoteSourceSvrDiedFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -66,6 +71,6 @@ ohos_fuzztest("DscreenSinkProxyFuzzTest") { ############################################################################### group("fuzztest") { testonly = true - deps = [ ":DscreenSinkProxyFuzzTest" ] + deps = [ ":HandlerOnRemoteSourceSvrDiedFuzzTest" ] } ############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/corpus/init similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/corpus/init diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp similarity index 50% rename from services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp index 46058019..72b35c38 100644 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.cpp @@ -13,34 +13,38 @@ * limitations under the License. */ -#include "screen_data_channel_fuzzer.h" +#include "onremotesourcesvrdied_fuzzer.h" #include #include -#include "screen_data_channel_impl.h" -#include "screen_sink_trans.h" -#include "screen_source_trans.h" +#include "dscreen_source_handler.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { -void ScreenDataChannelFuzzTest(const uint8_t* data, size_t size) +void OnRemoteSourceSvrDiedFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { return; } - std::string peerDevId(reinterpret_cast(data), size); - std::shared_ptr screenDataChannelImpl = std::make_shared(peerDevId); - std::shared_ptr listener = std::make_shared(); - size_t capacity = size; - std::shared_ptr screenData = std::make_shared(capacity); - - screenDataChannelImpl->CreateSession(listener); - screenDataChannelImpl->OpenSession(); - screenDataChannelImpl->SendData(screenData); - screenDataChannelImpl->CloseSession(); - screenDataChannelImpl->ReleaseSession(); + int32_t saId = *(reinterpret_cast(data)); + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } + + sptr remoteObject = samgr->GetSystemAbility(saId); + if (remoteObject == nullptr) { + return; + } + + wptr remote(remoteObject); + + DScreenSourceHandler::GetInstance().OnRemoteSourceSvrDied(remote); } } } @@ -49,7 +53,6 @@ void ScreenDataChannelFuzzTest(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::ScreenDataChannelFuzzTest(data, size); - + OHOS::DistributedHardware::OnRemoteSourceSvrDiedFuzzTest(data, size); return 0; } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.h similarity index 82% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.h index 6a8a9812..ce11ef1c 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/onremotesourcesvrdied_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef DSCREEN_SOURCE_PROXY_FUZZER_H -#define DSCREEN_SOURCE_PROXY_FUZZER_H +#ifndef ONREMOTESOURCESVRDIED_FUZZER_H +#define ONREMOTESOURCESVRDIED_FUZZER_H -#define FUZZ_PROJECT_NAME "dscreen_source_proxy_fuzzer" +#define FUZZ_PROJECT_NAME "onremotesourcesvrdied_fuzzer" #endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/project.xml similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..5964fe12 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("HandlerRegisterDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourcehandler" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "registerdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"HandlerRegisterDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":HandlerRegisterDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/corpus/init similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/corpus/init diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/project.xml similarity index 100% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp new file mode 100644 index 00000000..1ce18dca --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * 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 "registerdistributedhardware_fuzzer.h" + +#include +#include + +#include "component_enable.h" +#include "dscreen_source_handler.h" + +namespace OHOS { +namespace DistributedHardware { +void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string version(reinterpret_cast(data), size); + std::string attrs(reinterpret_cast(data), size); + EnableParam param; + param.version = version; + param.attrs = attrs; + std::shared_ptr callback = std::make_shared(); + + DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::RegisterDistributedHardwareFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h new file mode 100644 index 00000000..d7a4cc55 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h @@ -0,0 +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 REGISTERDISTRIBUTEDHARDWARE_FUZZER_H +#define REGISTERDISTRIBUTEDHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "registerdistributedhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..7af233b1 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("HandlerUnregisterDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourcehandler" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "unregisterdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"HandlerUnregisterDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":HandlerUnregisterDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/corpus/init similarity index 100% rename from services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/corpus/init diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/project.xml similarity index 100% rename from screenhandler/test/fuzztest/dscreenhandler_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp new file mode 100644 index 00000000..6a36a164 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * 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 "unregisterdistributedhardware_fuzzer.h" + +#include +#include + +#include "component_disable.h" +#include "dscreen_source_handler.h" + +namespace OHOS { +namespace DistributedHardware { +void UnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::shared_ptr uncallback = std::make_shared(); + + DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, uncallback); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::UnregisterDistributedHardwareFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h new file mode 100644 index 00000000..f91da2d6 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h @@ -0,0 +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 UNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H +#define UNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "unregisterdistributedhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..51ed588b --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ProxyConfigDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourceproxy" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "configdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ProxyConfigDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ProxyConfigDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp similarity index 63% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp index 32399053..dca97995 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -13,41 +13,28 @@ * limitations under the License. */ -#include "dscreen_source_proxy_fuzzer.h" +#include "configdistributedhardware_fuzzer.h" #include #include #include "dscreen_constants.h" -#include "dscreen_source_callback.h" #include "dscreen_source_proxy.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { -void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) +void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size <= 0)) { return; } - std::string params(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); std::string devId(reinterpret_cast(data), size); - std::string reqId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); std::string key(reinterpret_cast(data), size); std::string value(reinterpret_cast(data), size); - int32_t eventCode = *(reinterpret_cast(data)); - std::string eventContent(reinterpret_cast(data), size); - std::string str(reinterpret_cast(data), size); - EnableParam param; - param.version = str; - param.attrs = str; - sptr callback = new DScreenSourceCallback(); - if (callback == nullptr) { - return; - } sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -62,12 +49,7 @@ void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); - dscreenSourceProxy->InitSource(params, callback); - dscreenSourceProxy->ReleaseSource(); - dscreenSourceProxy->RegisterDistributedHardware(devId, dhId, param, reqId); - dscreenSourceProxy->UnregisterDistributedHardware(devId, dhId, reqId); dscreenSourceProxy->ConfigDistributedHardware(devId, dhId, key, value); - dscreenSourceProxy->DScreenNotify(devId, eventCode, eventContent); } } } @@ -76,6 +58,6 @@ void DscreenSourceProxyHandlerFuzzTest(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::DscreenSourceProxyHandlerFuzzTest(data, size); + OHOS::DistributedHardware::ConfigDistributedHardwareFuzzTest(data, size); return 0; } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h new file mode 100644 index 00000000..c9f1c3d0 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.h @@ -0,0 +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 CONFIGDISTRIBUTEDHARDWARE_FUZZER_H +#define CONFIGDISTRIBUTEDHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "configdistributedhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/corpus/init similarity index 100% rename from services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/corpus/init diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/project.xml similarity index 100% rename from services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn similarity index 68% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn index 9be51b4f..28bd06f4 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn @@ -18,10 +18,10 @@ import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("DscreenSinkHandlerFuzzTest") { - module_out_path = "distributed_screen/dscreensinkhandler" +ohos_fuzztest("ProxyDScreenNotifyFuzzTest") { + module_out_path = "distributed_screen/dscreensourceproxy" - fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer" + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer" include_dirs = [ "//utils/system/safwk/native/include", @@ -30,8 +30,12 @@ ohos_fuzztest("DscreenSinkHandlerFuzzTest") { include_dirs += [ "include", + "include/callback", "${common_path}/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", ] cflags = [ @@ -41,17 +45,18 @@ ohos_fuzztest("DscreenSinkHandlerFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dscreen_sink_handler_fuzzer.cpp" ] + sources = [ "dscreennotify_fuzzer.cpp" ] deps = [ "${common_path}:distributed_screen_utils", - "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", "//utils/native/base:utils", ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenSinkHandlerFuzzTest\"", + "DH_LOG_TAG=\"ProxyDScreenNotifyFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -66,6 +71,6 @@ ohos_fuzztest("DscreenSinkHandlerFuzzTest") { ############################################################################### group("fuzztest") { testonly = true - deps = [ ":DscreenSinkHandlerFuzzTest" ] + deps = [ ":ProxyDScreenNotifyFuzzTest" ] } ############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/corpus/init similarity index 100% rename from services/screentransport/test/fuzztest/screensinktrans_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/corpus/init diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp similarity index 62% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp index 1888eb30..77dcd719 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp @@ -13,27 +13,24 @@ * limitations under the License. */ -#include "dscreen_sink_proxy_fuzzer.h" +#include "dscreennotify_fuzzer.h" #include #include #include "dscreen_constants.h" -#include "dscreen_sink_proxy.h" +#include "dscreen_source_proxy.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { -void DscreenSinkProxyHandlerFuzzTest(const uint8_t* data, size_t size) +void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= sizeof(int32_t))) { + if ((data == nullptr) || (size <= 0)) { return; } - std::string params(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - std::string param(reinterpret_cast(data), size); std::string devId(reinterpret_cast(data), size); int32_t eventCode = *(reinterpret_cast(data)); std::string eventContent(reinterpret_cast(data), size); @@ -44,18 +41,14 @@ void DscreenSinkProxyHandlerFuzzTest(const uint8_t* data, size_t size) return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); if (remoteObject == nullptr) { return; } - std::shared_ptr dscreenSinkProxy = std::make_shared(remoteObject); + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); - dscreenSinkProxy->DScreenNotify(devId, eventCode, eventContent); - dscreenSinkProxy->InitSink(params); - dscreenSinkProxy->SubscribeLocalHardware(dhId, param); - dscreenSinkProxy->UnsubscribeLocalHardware(dhId); - dscreenSinkProxy->ReleaseSink(); + dscreenSourceProxy->DScreenNotify(devId, eventCode, eventContent); } } } @@ -64,7 +57,6 @@ void DscreenSinkProxyHandlerFuzzTest(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::DscreenSinkProxyHandlerFuzzTest(data, size); + OHOS::DistributedHardware::DScreenNotifyFuzzTest(data, size); return 0; -} - +} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.h similarity index 83% rename from services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.h index 10783fc0..b77ec6f3 100644 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef SCREEN_SINK_TRANS_FUZZER_H -#define SCREEN_SINK_TRANS_FUZZER_H +#ifndef DSCREENNOTIFY_FUZZER_H +#define DSCREENNOTIFY_FUZZER_H -#define FUZZ_PROJECT_NAME "screen_sink_trans_fuzzer" +#define FUZZ_PROJECT_NAME "dscreennotify_fuzzer" #endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/project.xml similarity index 100% rename from services/screentransport/test/fuzztest/screensinktrans_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn similarity index 91% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn index 7585b822..dca2b5e6 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn @@ -18,10 +18,10 @@ import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("DscreenSourceProxyFuzzTest") { +ohos_fuzztest("ProxyInitSourceFuzzTest") { module_out_path = "distributed_screen/dscreensourceproxy" - fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer" + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer" include_dirs = [ "//utils/system/safwk/native/include", @@ -45,7 +45,7 @@ ohos_fuzztest("DscreenSourceProxyFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dscreen_source_proxy_fuzzer.cpp" ] + sources = [ "initsource_fuzzer.cpp" ] deps = [ "${common_path}:distributed_screen_utils", @@ -56,7 +56,7 @@ ohos_fuzztest("DscreenSourceProxyFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenSourceProxyFuzzTest\"", + "DH_LOG_TAG=\"ProxyInitSourceFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -71,6 +71,6 @@ ohos_fuzztest("DscreenSourceProxyFuzzTest") { ############################################################################### group("fuzztest") { testonly = true - deps = [ ":DscreenSourceProxyFuzzTest" ] + deps = [ ":ProxyInitSourceFuzzTest" ] } ############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/corpus/init similarity index 100% rename from services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/corpus/init diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp similarity index 62% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.cpp rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp index 66853e0d..01f5e3ef 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/dscreen_sink_handler_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.cpp @@ -13,37 +13,46 @@ * limitations under the License. */ -#include "dscreen_sink_handler_fuzzer.h" +#include "initsource_fuzzer.h" #include #include #include "dscreen_constants.h" -#include "dscreen_sink_handler.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { -void DscreenSinkHandlerFuzzTest(const uint8_t* data, size_t size) +void InitSourceFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size <= 0)) { return; } std::string params(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - std::string param(reinterpret_cast(data), size); + + sptr callback = new DScreenSourceCallback(); + if (callback == nullptr) { + return; + } sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); - wptr remote (remoteObject); - DScreenSinkHandler::GetInstance().InitSink(params); - DScreenSinkHandler::GetInstance().SubscribeLocalHardware(dhId, param); - DScreenSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId); - DScreenSinkHandler::GetInstance().ReleaseSink(); - DScreenSinkHandler::GetInstance().OnRemoteSinkSvrDied(remote); + if (samgr == nullptr) { + return; + } + + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + if (remoteObject == nullptr) { + return; + } + + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); + + dscreenSourceProxy->InitSource(params, callback); } } } @@ -52,7 +61,6 @@ void DscreenSinkHandlerFuzzTest(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::DscreenSinkHandlerFuzzTest(data, size); + OHOS::DistributedHardware::InitSourceFuzzTest(data, size); return 0; -} - +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.h similarity index 83% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.h rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.h index f6b47fd0..49061f6b 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.h +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/initsource_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef DCREEN_SINK_PROXY_FUZZER_H -#define DCREEN_SINK_PROXY_FUZZER_H +#ifndef INITSOURCE_FUZZER_H +#define INITSOURCE_FUZZER_H -#define FUZZ_PROJECT_NAME "dscreen_sink_proxy_fuzzer" +#define FUZZ_PROJECT_NAME "initsource_fuzzer" #endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/project.xml similarity index 100% rename from services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..4a0fce97 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ProxyRegisterDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourceproxy" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "registerdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ProxyRegisterDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ProxyRegisterDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/corpus/init similarity index 100% rename from services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/corpus/init diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/project.xml similarity index 100% rename from services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp similarity index 52% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.cpp rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp index 9bfc6fef..0ce21584 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -13,49 +13,48 @@ * limitations under the License. */ -#include "dscreen_source_handler_fuzzer.h" +#include "registerdistributedhardware_fuzzer.h" #include #include -#include "component_disable.h" -#include "component_enable.h" #include "dscreen_constants.h" -#include "dscreen_source_handler.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { -void DscreenSourceHandlerFuzzTest(const uint8_t* data, size_t size) +void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size <= 0)) { return; } - std::string params(reinterpret_cast(data), size); std::string devId(reinterpret_cast(data), size); std::string dhId(reinterpret_cast(data), size); - std::string key(reinterpret_cast(data), size); - std::string value(reinterpret_cast(data), size); - std::string str(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + std::string version(reinterpret_cast(data), size); + std::string attrs(reinterpret_cast(data), size); EnableParam param; - param.version = str; - param.attrs = str; - std::shared_ptr callback = std::make_shared(); - std::shared_ptr uncallback = std::make_shared(); + param.version = version; + param.attrs = attrs; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); - wptr remote (remoteObject); + if (remoteObject == nullptr) { + return; + } + + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); - DScreenSourceHandler::GetInstance().InitSource(params); - DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); - DScreenSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); - DScreenSourceHandler::GetInstance().UnregisterDistributedHardware(devId, dhId, uncallback); - DScreenSourceHandler::GetInstance().ReleaseSource(); - DScreenSourceHandler::GetInstance().OnRemoteSourceSvrDied(remote); + dscreenSourceProxy->RegisterDistributedHardware(devId, dhId, param, reqId); } } } @@ -64,6 +63,6 @@ void DscreenSourceHandlerFuzzTest(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::DscreenSourceHandlerFuzzTest(data, size); + OHOS::DistributedHardware::RegisterDistributedHardwareFuzzTest(data, size); return 0; } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h new file mode 100644 index 00000000..d7a4cc55 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.h @@ -0,0 +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 REGISTERDISTRIBUTEDHARDWARE_FUZZER_H +#define REGISTERDISTRIBUTEDHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "registerdistributedhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..f851ef87 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ProxyUnregisterDistributedHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreensourceproxy" + + fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer" + + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "unregisterdistributedhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ProxyUnregisterDistributedHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ProxyUnregisterDistributedHardwareFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/corpus/init similarity index 100% rename from services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/corpus/init diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/project.xml similarity index 100% rename from services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml rename to interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/project.xml diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp new file mode 100644 index 00000000..9dbf372c --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp @@ -0,0 +1,63 @@ +/* + * 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 "unregisterdistributedhardware_fuzzer.h" + +#include +#include + +#include "dscreen_constants.h" +#include "dscreen_source_callback.h" +#include "dscreen_source_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void UnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } + + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + if (remoteObject == nullptr) { + return; + } + + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); + + dscreenSourceProxy->UnregisterDistributedHardware(devId, dhId, reqId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::UnregisterDistributedHardwareFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h new file mode 100644 index 00000000..f91da2d6 --- /dev/null +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.h @@ -0,0 +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 UNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H +#define UNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "unregisterdistributedhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/screenhandler/test/fuzztest/BUILD.gn b/screenhandler/test/fuzztest/BUILD.gn index 9c99a47e..d0a9fd68 100644 --- a/screenhandler/test/fuzztest/BUILD.gn +++ b/screenhandler/test/fuzztest/BUILD.gn @@ -14,5 +14,9 @@ group("fuzztest") { testonly = true - deps = [ "dscreenhandler_fuzzer:fuzztest" ] + deps = [ + "pluginhardware_fuzzer:fuzztest", + "registerpluginlistener_fuzzer:fuzztest", + "unpluginhardware_fuzzer:fuzztest", + ] } diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn similarity index 92% rename from screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn rename to screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn index d637f5ed..aed66476 100644 --- a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn @@ -18,10 +18,10 @@ import( "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("DscreenHandlerFuzzTest") { +ohos_fuzztest("PluginHardwareFuzzTest") { module_out_path = "distributed_screen/dscreenhandler" - fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/dscreenhandler_fuzzer" + fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/pluginhardware_fuzzer" include_dirs = [ "//third_party/json/include", @@ -45,7 +45,7 @@ ohos_fuzztest("DscreenHandlerFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "dscreen_handler_fuzzer.cpp" ] + sources = [ "pluginhardware_fuzzer.cpp" ] deps = [ "${common_path}:distributed_screen_utils", @@ -60,7 +60,7 @@ ohos_fuzztest("DscreenHandlerFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DscreenHandlerFuzzTest\"", + "DH_LOG_TAG=\"PluginHardwareFuzzTest\"", "LOG_DOMAIN=0xD004100", ] @@ -71,6 +71,6 @@ ohos_fuzztest("DscreenHandlerFuzzTest") { group("fuzztest") { testonly = true deps = [] - deps += [ ":DscreenHandlerFuzzTest" ] + deps += [ ":PluginHardwareFuzzTest" ] } ############################################################################### diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/corpus/init b/screenhandler/test/fuzztest/pluginhardware_fuzzer/corpus/init similarity index 100% rename from screenhandler/test/fuzztest/dscreenhandler_fuzzer/corpus/init rename to screenhandler/test/fuzztest/pluginhardware_fuzzer/corpus/init diff --git a/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp new file mode 100644 index 00000000..b5ee154d --- /dev/null +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * 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 "pluginhardware_fuzzer.h" + +#include +#include + +#include "dscreen_handler.h" + +namespace OHOS { +namespace DistributedHardware { +void PluginHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + std::string attr(reinterpret_cast(data), size); + + DScreenHandler::GetInstance().PluginHardware(dhId, attr); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::PluginHardwareFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.h similarity index 82% rename from services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h rename to screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.h index 73d19ac7..3dbceeb2 100644 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef SCREEN_DATA_CHANNEL_FUZZER_H -#define SCREEN_DATA_CHANNEL_FUZZER_H +#ifndef PLUGINHARDWARE_FUZZ_H +#define PLUGINHARDWARE_FUZZ_H -#define FUZZ_PROJECT_NAME "screen_data_channel_fuzzer" +#define FUZZ_PROJECT_NAME "pluginhardware_fuzzer" #endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml b/screenhandler/test/fuzztest/pluginhardware_fuzzer/project.xml similarity index 98% rename from services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml rename to screenhandler/test/fuzztest/pluginhardware_fuzzer/project.xml index 27c26d11..6e8ad2cf 100644 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/project.xml @@ -22,4 +22,4 @@ 4096 - \ No newline at end of file + diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn new file mode 100644 index 00000000..adef07b4 --- /dev/null +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("RegisterPluginListenerFuzzTest") { + module_out_path = "distributed_screen/dscreenhandler" + + fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/registerpluginlistener_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "${windowmanager_path}/interfaces/innerkits/dm", + "${mediastandard_path}/interfaces/innerkits/native/media/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${distributedscreen_path}/screenhandler/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/localhardwaremanager", + "//foundation/distributedhardware/distributed_hardware_fwk/common/utils/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "registerpluginlistener_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${distributedscreen_path}/screenhandler:distributed_screen_handler", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${mediastandard_path}/interfaces/inner_api/native:media_client", + "${windowmanager_path}/dm:libdm", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"RegisterPluginListenerFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":RegisterPluginListenerFuzzTest" ] +} +############################################################################### diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/corpus/init b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/corpus/init @@ -0,0 +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. + */ + +FUZZ \ No newline at end of file diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/project.xml b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.cpp b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp similarity index 59% rename from screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.cpp rename to screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp index 99120d32..05717083 100644 --- a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/dscreen_handler_fuzzer.cpp +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.cpp @@ -13,21 +13,18 @@ * limitations under the License. */ -#include "dscreen_handler_fuzzer.h" +#include "registerpluginlistener_fuzzer.h" #include #include -#include #include "dscreen_handler.h" #include "device_type.h" -#include "ihardware_handler.h" -#include "local_hardware_manager.h" #include "plugin_listener_impl.h" namespace OHOS { namespace DistributedHardware { -void DscreenHandlerFuzzTest(const uint8_t* data, size_t size) +void RegisterPluginListenerFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size <= 0)) { return; @@ -35,18 +32,8 @@ void DscreenHandlerFuzzTest(const uint8_t* data, size_t size) DHType dhType = DHType::DISPLAY; std::shared_ptr listener = std::make_shared(dhType); - std::string dhId(reinterpret_cast(data), size); - std::string attr(reinterpret_cast(data), size); - DScreenHandler::GetInstance().Initialize(); - DScreenHandler::GetInstance().Query(); - DScreenHandler::GetInstance().QueryExtraInfo(); - DScreenHandler::GetInstance().IsSupportPlugin(); DScreenHandler::GetInstance().RegisterPluginListener(listener); - DScreenHandler::GetInstance().PluginHardware(dhId, attr); - DScreenHandler::GetInstance().UnPluginHardware(dhId); - DScreenHandler::GetInstance().UnRegisterPluginListener(); - DScreenHandler::GetInstance().QueryCodecInfo(); } } } @@ -55,7 +42,7 @@ void DscreenHandlerFuzzTest(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::DscreenHandlerFuzzTest(data, size); + OHOS::DistributedHardware::RegisterPluginListenerFuzzTest(data, size); return 0; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.h b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.h similarity index 81% rename from interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.h rename to screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.h index 60ea1677..dabdd3ee 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/dscreen_source_handler_fuzzer.h +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/registerpluginlistener_fuzzer.h @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef DSCREEN_SOURCE_HANDLER_FUZZER_H -#define DSCREEN_SOURCE_HANDLER_FUZZER_H +#ifndef REGISTERPLUGINLISTENER_FUZZER_H +#define REGISTERPLUGINLISTENER_FUZZER_H -#define FUZZ_PROJECT_NAME "dscreen_source_handler_fuzzer" +#define FUZZ_PROJECT_NAME "registerpluginlistener_fuzzer" #endif \ No newline at end of file diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn new file mode 100644 index 00000000..4c526b3d --- /dev/null +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("UnPluginHardwareFuzzTest") { + module_out_path = "distributed_screen/dscreenhandler" + + fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/unpluginhardware_fuzzer" + + include_dirs = [ + "//third_party/json/include", + "${windowmanager_path}/interfaces/innerkits/dm", + "${mediastandard_path}/interfaces/innerkits/native/media/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "${common_path}/include", + "${distributedscreen_path}/screenhandler/include", + "${fwk_services_path}/distributedhardwarefwkserviceimpl/include/localhardwaremanager", + "//foundation/distributedhardware/distributed_hardware_fwk/common/utils/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "unpluginhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_screen_utils", + "${distributedscreen_path}/screenhandler:distributed_screen_handler", + "${fwk_services_path}/distributedhardwarefwkserviceimpl:distributedhardwarefwksvr_impl", + "${mediastandard_path}/interfaces/inner_api/native:media_client", + "${windowmanager_path}/dm:libdm", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"UnPluginHardwareFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":UnPluginHardwareFuzzTest" ] +} +############################################################################### diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/corpus/init b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/corpus/init new file mode 100644 index 00000000..8eb5a7d6 --- /dev/null +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/corpus/init @@ -0,0 +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. + */ + +FUZZ \ No newline at end of file diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/project.xml b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/project.xml new file mode 100644 index 00000000..6e8ad2cf --- /dev/null +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp new file mode 100644 index 00000000..1678eff2 --- /dev/null +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "unpluginhardware_fuzzer.h" + +#include +#include + +#include "dscreen_handler.h" + +namespace OHOS { +namespace DistributedHardware { +void UnPluginHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + + DScreenHandler::GetInstance().UnPluginHardware(dhId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::UnPluginHardwareFuzzTest(data, size); + return 0; +} + diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.h b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.h new file mode 100644 index 00000000..4ea97e56 --- /dev/null +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/unpluginhardware_fuzzer.h @@ -0,0 +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 UNPLUGINHARDWARE_FUZZER_H +#define UNPLUGINHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "unpluginhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn deleted file mode 100644 index 1f508824..00000000 --- a/services/screentransport/test/fuzztest/BUILD.gn +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -group("fuzztest") { - testonly = true - - deps = [ - "screendatachannel_fuzzer:fuzztest", - "screensinkprocessor_fuzzer:fuzztest", - "screensinktrans_fuzzer:fuzztest", - "screensourceprocessor_fuzzer:fuzztest", - "screensourcetrans_fuzzer:fuzztest", - ] -} diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn deleted file mode 100644 index fd92a54d..00000000 --- a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ScreenDataChannelFuzzTest") { - module_out_path = "distributed_screen/screendatachannel" - - fuzz_config_file = - "${services_path}/screentransport/test/fuzztest/screendatachannel_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - ] - - include_dirs += [ - "./include", - "${services_path}/screentransport/test/unittest/screentranstestutils/include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "screen_data_channel_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ScreenDataChannelFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ScreenDataChannelFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn deleted file mode 100644 index 0724ecc6..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/BUILD.gn +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ScreenSinkProcessorFuzzTest") { - module_out_path = "distributed_screen/screensinkprocessor" - - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - ] - - include_dirs += [ - "./include", - "${services_path}/screentransport/test/unittest/screentranstestutils/include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/softbusadapter/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "screen_sink_processor_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ScreenSinkProcessorFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ScreenSinkProcessorFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp deleted file mode 100644 index 06e36069..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "screen_sink_processor_fuzzer.h" - -#include -#include -#include - -#include "image_sink_processor.h" -#include "screen_sink_trans.h" - -namespace OHOS { -namespace DistributedHardware { -void ScreenSinkProcessorFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size <= 0)) { - return; - } - - std::shared_ptr imageSinkProcessor = std::make_shared(); - std::shared_ptr param = std::make_shared(); - uint32_t screenWidth = *(reinterpret_cast(data)); - uint32_t screenHeight = *(reinterpret_cast(data)); - uint32_t videoWidth = *(reinterpret_cast(data)); - uint32_t videoHeight = *(reinterpret_cast(data)); - param->SetScreenWidth(screenWidth); - param->SetScreenHeight(screenHeight); - param->SetVideoWidth(videoWidth); - param->SetScreenHeight(videoHeight); - std::shared_ptr imageListener = std::make_shared(); - std::string name(reinterpret_cast(data), size); - sptr surface = Surface::CreateSurfaceAsConsumer(name); - size_t capacity = size; - std::shared_ptr screenData = std::make_shared(capacity); - - imageSinkProcessor->SetImageSurface(surface); - imageSinkProcessor->ConfigureImageProcessor(*param, *param, imageListener); - imageSinkProcessor->ProcessImage(screenData); - imageSinkProcessor->StartImageProcessor(); - imageSinkProcessor->StopImageProcessor(); - imageSinkProcessor->ReleaseImageProcessor(); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ScreenSinkProcessorFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h b/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h deleted file mode 100644 index e56562c9..00000000 --- a/services/screentransport/test/fuzztest/screensinkprocessor_fuzzer/screen_sink_processor_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SCREEN_SINK_PROCESSOR_FUZZER_H -#define SCREEN_SINK_PROCESSOR_FUZZER_H - -#define FUZZ_PROJECT_NAME "screen_sink_processor_fuzzer" - -#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn deleted file mode 100644 index 48bdcdb9..00000000 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/BUILD.gn +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ScreenSinkTransFuzzTest") { - module_out_path = "distributed_screen/screensinktrans" - - fuzz_config_file = - "${services_path}/screentransport/test/fuzztest/screensinktrans_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - ] - - include_dirs += [ - "./include", - "${services_path}/screentransport/test/unittest/screentranstestutils/include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/softbusadapter/include", - "${services_path}/screenservice/sinkservice/screenregionmgr/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "screen_sink_trans_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${services_path}/screenservice/sinkservice:distributed_screen_sink", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ScreenSinkTransFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ScreenSinkTransFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp deleted file mode 100644 index 4c7a4717..00000000 --- a/services/screentransport/test/fuzztest/screensinktrans_fuzzer/screen_sink_trans_fuzzer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "screen_sink_trans_fuzzer.h" - -#include -#include -#include - -#include "screenregion.h" -#include "screen_sink_trans.h" -#include "screentrans_test_utils.h" - -namespace OHOS { -namespace DistributedHardware { -void ScreenSinkTransFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size <= 0)) { - return; - } - - std::shared_ptr screenSinkTrans = std::make_shared(); - std::shared_ptr param = std::make_shared(); - uint32_t screenWidth = *(reinterpret_cast(data)); - uint32_t screenHeight = *(reinterpret_cast(data)); - uint32_t videoWidth = *(reinterpret_cast(data)); - uint32_t videoHeight = *(reinterpret_cast(data)); - param->SetScreenWidth(screenWidth); - param->SetScreenHeight(screenHeight); - param->SetVideoWidth(videoWidth); - param->SetScreenHeight(videoHeight); - std::string peerDevId(reinterpret_cast(data), size); - std::string remoteDevId(reinterpret_cast(data), size); - uint64_t screenId = *(reinterpret_cast(data)); - uint64_t displayId = *(reinterpret_cast(data)); - std::shared_ptr callBack = - std::make_shared(remoteDevId, screenId, displayId); - std::string name(reinterpret_cast(data), size); - sptr surface = Surface::CreateSurfaceAsConsumer(name); - - screenSinkTrans->SetUp(*param, *param, peerDevId); - screenSinkTrans->SetImageSurface(surface); - screenSinkTrans->Start(); - screenSinkTrans->RegisterStateCallback(callBack); - screenSinkTrans->Stop(); - screenSinkTrans->Release(); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ScreenSinkTransFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn deleted file mode 100644 index 36a68d0a..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ScreenSourceProcessorFuzzTest") { - module_out_path = "distributed_screen/screensourceprocessor" - - fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/", - ] - - include_dirs += [ - "./include", - "${services_path}/screentransport/test/unittest/screentranstestutils/include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/test/unittest/screensourcetrans", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - "${services_path}/screentransport/test/unittest/screensourceprocessor/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "screen_source_processor_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ScreenSourceProcessorFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ScreenSourceProcessorFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp deleted file mode 100644 index 688a95e1..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "screen_source_processor_fuzzer.h" - -#include -#include - -#include "image_source_processor.h" -#include "screen_source_trans.h" - -namespace OHOS { -namespace DistributedHardware { -void ScreenSourceProcessorFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(uint32_t))) { - return; - } - - std::shared_ptr imageSourceProcessor = std::make_shared(); - std::shared_ptr param = std::make_shared(); - uint32_t screenWidth = *(reinterpret_cast(data)); - uint32_t screenHeight = *(reinterpret_cast(data)); - uint32_t videoWidth = *(reinterpret_cast(data)); - uint32_t videoHeight = *(reinterpret_cast(data)); - param->SetScreenWidth(screenWidth); - param->SetScreenHeight(screenHeight); - param->SetVideoWidth(videoWidth); - param->SetScreenHeight(videoHeight); - std::shared_ptr listener = std::make_shared(); - - imageSourceProcessor->ConfigureImageProcessor(*param, *param, listener); - imageSourceProcessor->GetImageSurface(); - imageSourceProcessor->StartImageProcessor(); - imageSourceProcessor->StopImageProcessor(); - imageSourceProcessor->ReleaseImageProcessor(); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ScreenSourceProcessorFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h deleted file mode 100644 index 36cfae08..00000000 --- a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SCREEN_SOURCE_PROCESSOR_FUZZER_H -#define SCREEN_SOURCE_PROCESSOR_FUZZER_H - -#define FUZZ_PROJECT_NAME "screen_source_processor_fuzzer" - -#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn deleted file mode 100644 index ce7f478f..00000000 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("ScreenSourceTransFuzzTest") { - module_out_path = "distributed_screen/screensourcetrans" - - fuzz_config_file = - "${services_path}/screentransport/test/fuzztest/screensourcetrans_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${windowmanager_path}/interfaces/innerkits/dm", - "${fwk_common_path}/log/include", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/", - "${fwk_utils_path}/include/log", - ] - - include_dirs += [ - "./include", - "${services_path}/screentransport/test/unittest/screentranstestutils/include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/test/unittest/screensourcetrans/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - "${services_path}/screenservice/sourceservice/dscreenmgr/include", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "screen_source_trans_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", - "${services_path}/screenservice/sourceservice:distributed_screen_source", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "${windowmanager_path}/dm:libdm", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ScreenSourceTransFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":ScreenSourceTransFuzzTest" ] -} -############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp deleted file mode 100644 index 50c6bea8..00000000 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "screen_source_trans_fuzzer.h" - -#include -#include - -#include "dscreen.h" -#include "dscreen_errcode.h" -#include "dscreen_manager.h" -#include "screen_source_trans.h" -#include "video_param.h" -#include "screentrans_test_utils.h" - -namespace OHOS { -namespace DistributedHardware { -void ScreenSourceTransFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(uint32_t))) { - return; - } - - std::shared_ptr screenSourceTrans = std::make_shared(); - std::shared_ptr param = std::make_shared(); - uint32_t screenWidth = *(reinterpret_cast(data)); - uint32_t screenHeight = *(reinterpret_cast(data)); - uint32_t videoWidth = *(reinterpret_cast(data)); - uint32_t videoHeight = *(reinterpret_cast(data)); - param->SetScreenWidth(screenWidth); - param->SetScreenHeight(screenHeight); - param->SetVideoWidth(videoWidth); - param->SetScreenHeight(videoHeight); - std::string peerDevId(reinterpret_cast(data), size); - std::string devId(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - std::shared_ptr dScreenCallback = std::make_shared(); - std::shared_ptr callBack = std::make_shared(devId, dhId, dScreenCallback); - - screenSourceTrans->SetUp(*param, *param, peerDevId); - screenSourceTrans->GetImageSurface(); - screenSourceTrans->Start(); - screenSourceTrans->RegisterStateCallback(callBack); - screenSourceTrans->Stop(); - screenSourceTrans->Release(); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ScreenSourceTransFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h deleted file mode 100644 index c5e54307..00000000 --- a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SCREEN_SOURCE_TRANS_FUZZER_H -#define SCREEN_SOURCE_TRANS_FUZZER_H - -#define FUZZ_PROJECT_NAME "screen_source_trans_fuzzer" - -#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn deleted file mode 100644 index 598cc3f3..00000000 --- a/services/softbusadapter/test/fuzztest/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -group("fuzztest") { - testonly = true - - deps = [ "softbusadapter_fuzzer:fuzztest" ] -} diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn deleted file mode 100644 index df00e0f1..00000000 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("SoftbusAdapterFuzzTest") { - module_out_path = "distributed_screen/softbusadapter" - - fuzz_config_file = - "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//foundation/graphic/graphic_2d/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/", - ] - - include_dirs += [ - "./include", - "${common_path}/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/common/utils/include", - "${services_path}/screentransport/test/unittest/screensourcetrans/include", - "${services_path}/screentransport/screensourcetrans/include", - "${services_path}/screentransport/screendatachannel/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/softbusadapter/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "softbus_adapter_fuzzer.cpp" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//foundation/graphic/graphic_2d/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "dsoftbus:softbus_client", - "hiviewdfx_hilog_native:libhilog", - "multimedia_media_standard:media_client", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":SoftbusAdapterFuzzTest" ] -} -############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp deleted file mode 100644 index 2a6345f5..00000000 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "softbus_adapter_fuzzer.h" - -#include -#include -#include - -#include "isoftbus_listener.h" -#include "screen_data_channel_impl.h" -#include "softbus_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -void SoftbusAdapterFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - - std::string pkgname(reinterpret_cast(data), size); - std::string sessionName(reinterpret_cast(data), size); - std::string peerDevId(reinterpret_cast(data), size); - std::string mySessionName(reinterpret_cast(data), size); - std::string peerSessionName(reinterpret_cast(data), size); - int32_t sessionId = *(reinterpret_cast(data)); - void *datapointer = const_cast(data); - int32_t dataLen = static_cast(size); - StreamData streamdata = {reinterpret_cast(const_cast(data)), static_cast(size)}; - StreamData ext = {0}; - StreamFrameInfo frameInfo = {0}; - std::shared_ptr listener = std::make_shared(peerDevId); - int32_t result = *(reinterpret_cast(data)); - unsigned int datalength = static_cast(size); - int eventId = *(reinterpret_cast(data)); - int tvCount = *(reinterpret_cast(data)); - QosTv tvList; - - SoftbusAdapter::GetInstance().CreateSoftbusSessionServer(pkgname, sessionName, peerDevId); - SoftbusAdapter::GetInstance().RemoveSoftbusSessionServer(pkgname, sessionName, peerDevId); - SoftbusAdapter::GetInstance().OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); - SoftbusAdapter::GetInstance().CloseSoftbusSession(sessionId); - SoftbusAdapter::GetInstance().SendSoftbusBytes(sessionId, datapointer, dataLen); - SoftbusAdapter::GetInstance().SendSoftbusStream(sessionId, &streamdata, &ext, &frameInfo); - SoftbusAdapter::GetInstance().RegisterSoftbusListener(listener, sessionName, peerDevId); - SoftbusAdapter::GetInstance().UnRegisterSoftbusListener(sessionName, peerDevId); - SoftbusAdapter::GetInstance().OnSoftbusSessionOpened(sessionId, result); - SoftbusAdapter::GetInstance().OnSoftbusSessionClosed(sessionId); - SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, datapointer, dataLen); - SoftbusAdapter::GetInstance().OnStreamReceived(sessionId, &streamdata, &ext, &frameInfo); - SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, datapointer, datalength); - SoftbusAdapter::GetInstance().OnQosEvent(sessionId, eventId, tvCount, &tvList); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::SoftbusAdapterFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h deleted file mode 100644 index f8959fec..00000000 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_SOFTBUS_ADAPTER_FUZZER_H -#define TEST_SOFTBUS_ADAPTER_FUZZER_H - -#define FUZZ_PROJECT_NAME "test_softbus_adapter_fuzzer" - -#endif \ No newline at end of file -- Gitee