diff --git a/bundle.json b/bundle.json index 6504186d01d19278502c622f2f009a8930e2a609..fb4934f11dad293191f130eb3c1b2af30f2052ab 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 da1ed29f842e9df19625ccbc8bddddb2665d59fa..a8229e8e27ad78d5e37f2317645f0fc0c48d8261 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 0000000000000000000000000000000000000000..ed8df58fcb7393b40e1a66504d9565152032b7ac --- /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 0000000000000000000000000000000000000000..cf1238d01b78a64aa8a20471e37b730d1d8adb34 --- /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 2d109e76d4dca871978ad31b5d7ba420a837f76d..c9f1c3d0cbf33ff0c3c7826a6982b06159b557cb 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 b04d3990046a1bbd667d6d7c7d5d4bc21ed0fd44..12ce376de73a76818379fd3eb187300a62656b69 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 0000000000000000000000000000000000000000..4d804239fe62c53ea8bd4fce8f869968a45b51c1 --- /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 7ca6e15b62d240518f8d7e1d1d54df678a859034..4cd4dbef22bad31a0f274766555ad78bad291727 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 eba246c78d3523c889039b471d4298955cabdaca..8964d77fe00ae14cac8a6fbfbdece41514a2b3e2 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 46058019dcde4b9f3450b91a4d6cfa0ac58e59c2..72b35c381372f617b1dbf6687ae0a311dcef3770 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 6a8a9812ea6b49b47b35ec55bc32ed99e81a2146..ce11ef1c20b20df3b0b5f0fa7b3f64a3dcde86f2 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 0000000000000000000000000000000000000000..5964fe1246458a00fea73b68c7c0e6e9d50d806c --- /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 0000000000000000000000000000000000000000..1ce18dca37f9e5caf1f4d38f1a7b2c1fe703d241 --- /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 0000000000000000000000000000000000000000..d7a4cc555e06a982941a95d720fecff661855784 --- /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 0000000000000000000000000000000000000000..7af233b19d386bb677e9d0fa44930f73408ce109 --- /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 0000000000000000000000000000000000000000..6a36a164629434db2c5914a0758228f2f0bc91c1 --- /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 0000000000000000000000000000000000000000..f91da2d68da35bf2a5c99eed4513c6629b0f92a2 --- /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 0000000000000000000000000000000000000000..51ed588b9156f7f9dea402764df61a9fa0d19a0d --- /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 3239905330ae50a5f6902c826f52029db2dc25c5..dca9799573d15bf7c0b902eb0a8fcfe80bf53d02 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 0000000000000000000000000000000000000000..c9f1c3d0cbf33ff0c3c7826a6982b06159b557cb --- /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 9be51b4fab5df3795b3ffb3c34f215b1708478fa..28bd06f4c62d7aa8557b7c1ee44220416da80384 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 1888eb30d9df2f4d7417b7b3c05fa98a4137a0c3..77dcd7196a75205e1574b5ff879600751543525f 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 10783fc031a707cd6d48bc599c235c2f1767647e..b77ec6f3c81c6509be205327cb49102e8a3605ce 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 7585b822163e74b3c0ab09adcc8e3f4e8016e575..dca2b5e671c2e9b067140de8b2a7ff5bd3bfc65a 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 66853e0d5b960147e02c987ed5f3b4e6ea1ab0b9..01f5e3ef8907d6e88cd0569908f4fb03a415368b 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 f6b47fd0ae17e9e32c38895eddb586e68fda691e..49061f6b456bb519f6d0692b6f94de17abb176e3 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 0000000000000000000000000000000000000000..4a0fce974aa605eef4e0fb611bbc2db0e7c9b48e --- /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 9bfc6fefa7e2dea52b025a7d1a30676a79cc1c46..0ce21584a41181c5ced5668a978dd91cac026347 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 0000000000000000000000000000000000000000..d7a4cc555e06a982941a95d720fecff661855784 --- /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 0000000000000000000000000000000000000000..f851ef87bb5f4df64f7a1a59d98e2008e88c446f --- /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 0000000000000000000000000000000000000000..9dbf372c5a8f54348edeca0af20e2b9e07439ac5 --- /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 0000000000000000000000000000000000000000..f91da2d68da35bf2a5c99eed4513c6629b0f92a2 --- /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 9c99a47eb31d894917cf48bf2cb0a9c03115dc07..d0a9fd683b4f72d2c098bd36197259e380a6ebd2 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 d637f5ed1a446356322a001fe659c480599f3fda..aed6647600fc2e965f282d00ce0ac5a425065461 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 0000000000000000000000000000000000000000..b5ee154d341b1d22e71f60f11c59ff3f30255ff4 --- /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 73d19ac775e2d7a3b3156144780217d8d8b0e720..3dbceeb2ef53e8366396caa2394e60176fdad62d 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 27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec 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 0000000000000000000000000000000000000000..adef07b4c51bfd6618c4ea7365dffd17f0432cef --- /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 0000000000000000000000000000000000000000..8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5 --- /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 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /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 99120d32819db24c715c5688fca9f1cd46627868..05717083eec86b4a420282e037fedb2f86002e30 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 60ea167743873074c9a22a12fa0038eca132a102..dabdd3ee8b00acc11b935a419441a187d61743f3 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 0000000000000000000000000000000000000000..4c526b3de20c011e4a5b55208a98365303ed74f9 --- /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 0000000000000000000000000000000000000000..8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5 --- /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 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /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 0000000000000000000000000000000000000000..1678eff253f768b519936b7f9e3e454aeccc058f --- /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 0000000000000000000000000000000000000000..4ea97e564926c826a354c6d8cda265fd9ed03b30 --- /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 1f508824a2d531c20eb962377a0fadae4b033466..0000000000000000000000000000000000000000 --- 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 fd92a54d490ddb9f6fc81eaad39fc0be675d2f87..0000000000000000000000000000000000000000 --- 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 0724ecc640110703694efc7ec89123540bc8e6a6..0000000000000000000000000000000000000000 --- 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 06e3606979540b2c28f8d55c2414e9e926cd2bb4..0000000000000000000000000000000000000000 --- 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 e56562c92819d15a5cea5dba01b42c8630b04158..0000000000000000000000000000000000000000 --- 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 48bdcdb9c8c41bd83791e15242bb9c0a8a3f1322..0000000000000000000000000000000000000000 --- 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 4c7a4717f539fd25a835662a0a7bd368f4113258..0000000000000000000000000000000000000000 --- 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 36a68d0af7ac5c99512a3fcadbc3bed40cd1f95d..0000000000000000000000000000000000000000 --- 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 688a95e16f70e518f5357d7f8d474adac18e1d98..0000000000000000000000000000000000000000 --- 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 36cfae0822e77e9c485314b8f56d4246c9f14ba3..0000000000000000000000000000000000000000 --- 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 ce7f478f53024ef2c1198e48ebf9d3c6abfb861c..0000000000000000000000000000000000000000 --- 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 50c6bea8148e45d71eb1642fde382aab25b8a87a..0000000000000000000000000000000000000000 --- 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 c5e54307bb91e6f24d4d1b9cb06abca1bca7c560..0000000000000000000000000000000000000000 --- 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 598cc3f332cc6315badc1a7f4416575c6838584d..0000000000000000000000000000000000000000 --- 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 df00e0f10f1acb7018d0d0c5e61151163a18b244..0000000000000000000000000000000000000000 --- 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 2a6345f5495d3e4b83f41f654d1b59df9c82d7d8..0000000000000000000000000000000000000000 --- 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 f8959fec9a504634fb35d6a4b59c03d10de023b4..0000000000000000000000000000000000000000 --- 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