!103 分布式屏幕Fuzz测试整改

Merge pull request !103 from qinlong/master
This commit is contained in:
openharmony_ci
2022-07-12 12:38:12 +00:00
committed by Gitee
85 changed files with 1319 additions and 1143 deletions
+1 -3
View File
@@ -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"
]
}
}
@@ -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",
]
}
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string key(reinterpret_cast<const char*>(data), size);
std::string value(reinterpret_cast<const char*>(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;
}
@@ -13,9 +13,9 @@
* limitations under the License.
*/
#ifndef DSCREEN_SOURCE_PROXY_FUZZER_H
#define DSCREEN_SOURCE_PROXY_FUZZER_H
#ifndef CONFIGDISTRIBUTEDHARDWARE_FUZZER_H
#define CONFIGDISTRIBUTEDHARDWARE_FUZZER_H
#define FUZZ_PROJECT_NAME "dscreen_source_proxy_fuzzer"
#define FUZZ_PROJECT_NAME "configdistributedhardware_fuzzer"
#endif
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -13,34 +13,38 @@
* limitations under the License.
*/
#include "screen_data_channel_fuzzer.h"
#include "onremotesourcesvrdied_fuzzer.h"
#include <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::shared_ptr<ScreenDataChannelImpl> screenDataChannelImpl = std::make_shared<ScreenDataChannelImpl>(peerDevId);
std::shared_ptr<IScreenChannelListener> listener = std::make_shared<ScreenSourceTrans>();
size_t capacity = size;
std::shared_ptr<DataBuffer> screenData = std::make_shared<DataBuffer>(capacity);
int32_t saId = *(reinterpret_cast<const int32_t*>(data));
sptr<ISystemAbilityManager> samgr =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (samgr == nullptr) {
return;
}
screenDataChannelImpl->CreateSession(listener);
screenDataChannelImpl->OpenSession();
screenDataChannelImpl->SendData(screenData);
screenDataChannelImpl->CloseSession();
screenDataChannelImpl->ReleaseSession();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId);
if (remoteObject == nullptr) {
return;
}
wptr<IRemoteObject> 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;
}
@@ -13,9 +13,9 @@
* limitations under the License.
*/
#ifndef DSCREEN_SINK_HANDLER_FUZZER_H
#define DSCREEN_SINK_HANDLER_FUZZER_H
#ifndef ONREMOTESOURCESVRDIED_FUZZER_H
#define ONREMOTESOURCESVRDIED_FUZZER_H
#define FUZZ_PROJECT_NAME "dscreen_sink_handler_fuzzer"
#define FUZZ_PROJECT_NAME "onremotesourcesvrdied_fuzzer"
#endif
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string version(reinterpret_cast<const char*>(data), size);
std::string attrs(reinterpret_cast<const char*>(data), size);
EnableParam param;
param.version = version;
param.attrs = attrs;
std::shared_ptr<RegisterCallback> callback = std::make_shared<ComponentEnable>();
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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::shared_ptr<UnregisterCallback> uncallback = std::make_shared<ComponentDisable>();
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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -13,41 +13,28 @@
* limitations under the License.
*/
#include "dscreen_source_proxy_fuzzer.h"
#include "configdistributedhardware_fuzzer.h"
#include <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string devId(reinterpret_cast<const char*>(data), size);
std::string reqId(reinterpret_cast<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string key(reinterpret_cast<const char*>(data), size);
std::string value(reinterpret_cast<const char*>(data), size);
int32_t eventCode = *(reinterpret_cast<const int32_t*>(data));
std::string eventContent(reinterpret_cast<const char*>(data), size);
std::string str(reinterpret_cast<const char*>(data), size);
EnableParam param;
param.version = str;
param.attrs = str;
sptr<IDScreenSourceCallback> callback = new DScreenSourceCallback();
if (callback == nullptr) {
return;
}
sptr<ISystemAbilityManager> samgr =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
@@ -62,12 +49,7 @@ void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size)
std::shared_ptr<IDScreenSource> dscreenSourceProxy = std::make_shared<DScreenSourceProxy>(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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -13,27 +13,24 @@
* limitations under the License.
*/
#include "dscreen_sink_proxy_fuzzer.h"
#include "dscreennotify_fuzzer.h"
#include <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string param(reinterpret_cast<const char*>(data), size);
std::string devId(reinterpret_cast<const char*>(data), size);
int32_t eventCode = *(reinterpret_cast<const int32_t*>(data));
std::string eventContent(reinterpret_cast<const char*>(data), size);
@@ -44,18 +41,14 @@ void DscreenSinkProxyHandlerFuzzTest(const uint8_t* data, size_t size)
return;
}
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID);
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID);
if (remoteObject == nullptr) {
return;
}
std::shared_ptr<DScreenSinkProxy> dscreenSinkProxy = std::make_shared<DScreenSinkProxy>(remoteObject);
std::shared_ptr<IDScreenSource> dscreenSourceProxy = std::make_shared<DScreenSourceProxy>(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;
}
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -13,37 +13,46 @@
* limitations under the License.
*/
#include "dscreen_sink_handler_fuzzer.h"
#include "initsource_fuzzer.h"
#include <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string param(reinterpret_cast<const char*>(data), size);
sptr<IDScreenSourceCallback> callback = new DScreenSourceCallback();
if (callback == nullptr) {
return;
}
sptr<ISystemAbilityManager> samgr =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID);
wptr<IRemoteObject> 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<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID);
if (remoteObject == nullptr) {
return;
}
std::shared_ptr<IDScreenSource> dscreenSourceProxy = std::make_shared<DScreenSourceProxy>(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;
}
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -13,49 +13,48 @@
* limitations under the License.
*/
#include "dscreen_source_handler_fuzzer.h"
#include "registerdistributedhardware_fuzzer.h"
#include <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string devId(reinterpret_cast<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string key(reinterpret_cast<const char*>(data), size);
std::string value(reinterpret_cast<const char*>(data), size);
std::string str(reinterpret_cast<const char*>(data), size);
std::string reqId(reinterpret_cast<const char*>(data), size);
std::string version(reinterpret_cast<const char*>(data), size);
std::string attrs(reinterpret_cast<const char*>(data), size);
EnableParam param;
param.version = str;
param.attrs = str;
std::shared_ptr<RegisterCallback> callback = std::make_shared<ComponentEnable>();
std::shared_ptr<UnregisterCallback> uncallback = std::make_shared<ComponentDisable>();
param.version = version;
param.attrs = attrs;
sptr<ISystemAbilityManager> samgr =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID);
wptr<IRemoteObject> remote (remoteObject);
if (samgr == nullptr) {
return;
}
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);
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID);
if (remoteObject == nullptr) {
return;
}
std::shared_ptr<IDScreenSource> dscreenSourceProxy = std::make_shared<DScreenSourceProxy>(remoteObject);
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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string devId(reinterpret_cast<const char*>(data), size);
std::string reqId(reinterpret_cast<const char*>(data), size);
sptr<ISystemAbilityManager> samgr =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (samgr == nullptr) {
return;
}
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID);
if (remoteObject == nullptr) {
return;
}
std::shared_ptr<IDScreenSource> dscreenSourceProxy = std::make_shared<DScreenSourceProxy>(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;
}
@@ -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
+5 -1
View File
@@ -14,5 +14,9 @@
group("fuzztest") {
testonly = true
deps = [ "dscreenhandler_fuzzer:fuzztest" ]
deps = [
"pluginhardware_fuzzer:fuzztest",
"registerpluginlistener_fuzzer:fuzztest",
"unpluginhardware_fuzzer:fuzztest",
]
}
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(data), size);
std::string attr(reinterpret_cast<const char*>(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;
}
@@ -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
@@ -22,4 +22,4 @@
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
</fuzz_config>
@@ -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" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -13,21 +13,18 @@
* limitations under the License.
*/
#include "dscreen_handler_fuzzer.h"
#include "registerpluginlistener_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <iostream>
#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<PluginListener> listener = std::make_shared<PluginListenerImpl>(dhType);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::string attr(reinterpret_cast<const char*>(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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -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 <cstddef>
#include <cstdint>
#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<const char*>(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;
}
@@ -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
@@ -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",
]
}
@@ -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" ]
}
###############################################################################
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#include <string>
#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> imageSinkProcessor = std::make_shared<ImageSinkProcessor>();
std::shared_ptr<VideoParam> param = std::make_shared<VideoParam>();
uint32_t screenWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t screenHeight = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoHeight = *(reinterpret_cast<const uint32_t*>(data));
param->SetScreenWidth(screenWidth);
param->SetScreenHeight(screenHeight);
param->SetVideoWidth(videoWidth);
param->SetScreenHeight(videoHeight);
std::shared_ptr<IImageSinkProcessorListener> imageListener = std::make_shared<ScreenSinkTrans>();
std::string name(reinterpret_cast<const char*>(data), size);
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer(name);
size_t capacity = size;
std::shared_ptr<DataBuffer> screenData = std::make_shared<DataBuffer>(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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#include <surface.h>
#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> screenSinkTrans = std::make_shared<ScreenSinkTrans>();
std::shared_ptr<VideoParam> param = std::make_shared<VideoParam>();
uint32_t screenWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t screenHeight = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoHeight = *(reinterpret_cast<const uint32_t*>(data));
param->SetScreenWidth(screenWidth);
param->SetScreenHeight(screenHeight);
param->SetVideoWidth(videoWidth);
param->SetScreenHeight(videoHeight);
std::string peerDevId(reinterpret_cast<const char*>(data), size);
std::string remoteDevId(reinterpret_cast<const char*>(data), size);
uint64_t screenId = *(reinterpret_cast<const uint64_t*>(data));
uint64_t displayId = *(reinterpret_cast<const uint64_t*>(data));
std::shared_ptr<IScreenSinkTransCallback> callBack =
std::make_shared<ScreenRegion>(remoteDevId, screenId, displayId);
std::string name(reinterpret_cast<const char*>(data), size);
sptr<Surface> 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;
}
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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> imageSourceProcessor = std::make_shared<ImageSourceProcessor>();
std::shared_ptr<VideoParam> param = std::make_shared<VideoParam>();
uint32_t screenWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t screenHeight = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoHeight = *(reinterpret_cast<const uint32_t*>(data));
param->SetScreenWidth(screenWidth);
param->SetScreenHeight(screenHeight);
param->SetVideoWidth(videoWidth);
param->SetScreenHeight(videoHeight);
std::shared_ptr<IImageSourceProcessorListener> listener = std::make_shared<ScreenSourceTrans>();
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;
}
@@ -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
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#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> screenSourceTrans = std::make_shared<ScreenSourceTrans>();
std::shared_ptr<VideoParam> param = std::make_shared<VideoParam>();
uint32_t screenWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t screenHeight = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoWidth = *(reinterpret_cast<const uint32_t*>(data));
uint32_t videoHeight = *(reinterpret_cast<const uint32_t*>(data));
param->SetScreenWidth(screenWidth);
param->SetScreenHeight(screenHeight);
param->SetVideoWidth(videoWidth);
param->SetScreenHeight(videoHeight);
std::string peerDevId(reinterpret_cast<const char*>(data), size);
std::string devId(reinterpret_cast<const char*>(data), size);
std::string dhId(reinterpret_cast<const char*>(data), size);
std::shared_ptr<IDScreenCallback> dScreenCallback = std::make_shared<DScreenCallback>();
std::shared_ptr<IScreenSourceTransCallback> callBack = std::make_shared<DScreen>(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;
}
@@ -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
@@ -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" ]
}
@@ -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" ]
}
###############################################################################
@@ -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 <cstddef>
#include <cstdint>
#include <string>
#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<const char*>(data), size);
std::string sessionName(reinterpret_cast<const char*>(data), size);
std::string peerDevId(reinterpret_cast<const char*>(data), size);
std::string mySessionName(reinterpret_cast<const char*>(data), size);
std::string peerSessionName(reinterpret_cast<const char*>(data), size);
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
void *datapointer = const_cast<uint8_t*>(data);
int32_t dataLen = static_cast<int32_t>(size);
StreamData streamdata = {reinterpret_cast<char*>(const_cast<uint8_t*>(data)), static_cast<int>(size)};
StreamData ext = {0};
StreamFrameInfo frameInfo = {0};
std::shared_ptr<ScreenDataChannelImpl> listener = std::make_shared<ScreenDataChannelImpl>(peerDevId);
int32_t result = *(reinterpret_cast<const int32_t*>(data));
unsigned int datalength = static_cast<unsigned int>(size);
int eventId = *(reinterpret_cast<const int*>(data));
int tvCount = *(reinterpret_cast<const int*>(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;
}
@@ -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