mirror of
https://github.com/openharmony/distributed_camera.git
synced 2026-07-20 00:54:12 -04:00
!154 fix: modify fuzz test
Merge pull request !154 from wangchaole/master
This commit is contained in:
@@ -15,10 +15,16 @@ group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"dcamerasinkhandleripc_fuzzer:fuzztest",
|
||||
"dcamerasinkloadcallback_fuzzer:fuzztest",
|
||||
"dcamerasinkproxy_fuzzer:fuzztest",
|
||||
"dcamerasourcehandleripc_fuzzer:fuzztest",
|
||||
"dcamerasourceloadcallback_fuzzer:fuzztest",
|
||||
"onsourcelocaldmsdied_fuzzer:fuzztest",
|
||||
"sourcehandlerconfigdistributedhardware_fuzzer:fuzztest",
|
||||
"sourcehandlerinitsource_fuzzer:fuzztest",
|
||||
"sourcehandlerregisterdistributedhardware_fuzzer:fuzztest",
|
||||
"sourcehandlerunregisterdistributedhardware_fuzzer:fuzztest",
|
||||
"sourceonloadsystemabilityfail_fuzzer:fuzztest",
|
||||
"sourceonloadsystemabilitysuccess_fuzzer:fuzztest",
|
||||
"sourceproxydcameranotify_fuzzer:fuzztest",
|
||||
"sourceproxyinitsource_fuzzer:fuzztest",
|
||||
"sourceproxyregisterdistributedhardware_fuzzer:fuzztest",
|
||||
"sourceproxyunregisterdistributedhardware_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
||||
+7
-6
@@ -18,10 +18,11 @@ import(
|
||||
"//foundation/distributedhardware/distributed_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DCameraSourceHandlerIpcFuzzTest") {
|
||||
module_out_path = "distributed_camera/dcamerasourcehandleripc"
|
||||
ohos_fuzztest("OnSourceLocalDmsDiedFuzzTest") {
|
||||
module_out_path = "distributed_camera/onsourcelocaldmsdied"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasourcehandleripc_fuzzer"
|
||||
fuzz_config_file =
|
||||
"${innerkits_path}/native_cpp/test/fuzztest/onsourcelocaldmsdied_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
@@ -45,7 +46,7 @@ ohos_fuzztest("DCameraSourceHandlerIpcFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dcamera_source_handler_ipc_fuzzer.cpp" ]
|
||||
sources = [ "onsourcelocaldmsdied_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
@@ -55,7 +56,7 @@ ohos_fuzztest("DCameraSourceHandlerIpcFuzzTest") {
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraSourceHandlerIpcFuzzTest\"",
|
||||
"DH_LOG_TAG=\"OnSourceLocalDmsDiedFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
@@ -71,6 +72,6 @@ ohos_fuzztest("DCameraSourceHandlerIpcFuzzTest") {
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DCameraSourceHandlerIpcFuzzTest" ]
|
||||
deps = [ ":OnSourceLocalDmsDiedFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+5
-7
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dcamera_source_handler_ipc_fuzzer.h"
|
||||
#include "onsourcelocaldmsdied_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -26,21 +26,19 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DCameraSourceHandlerIpcFuzzTest(const uint8_t* data, size_t size)
|
||||
void OnSourceLocalDmsDiedFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t saId = *(reinterpret_cast<const int32_t*>(data));
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId);
|
||||
wptr<IRemoteObject> remote (remoteObject);
|
||||
|
||||
DCameraSourceHandlerIpc::GetInstance().Init();
|
||||
DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS();
|
||||
DCameraSourceHandlerIpc::GetInstance().OnSourceLocalDmsDied(remote);
|
||||
DCameraSourceHandlerIpc::GetInstance().UnInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +47,6 @@ void DCameraSourceHandlerIpcFuzzTest(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::DCameraSourceHandlerIpcFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::OnSourceLocalDmsDiedFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DCAMERA_SINK_PROXY_FUZZER_H
|
||||
#define DCAMERA_SINK_PROXY_FUZZER_H
|
||||
#ifndef ONSOURCELOCALDMSDIED_FUZZER_H
|
||||
#define ONSOURCELOCALDMSDIED_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dcamera_sink_proxy_fuzzer"
|
||||
#define FUZZ_PROJECT_NAME "onsourcelocaldmsdied_fuzzer"
|
||||
|
||||
#endif
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2021 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceHandlerConfigDistributedHardwareFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourcehandlerconfigdistributedhardware"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourcehandlerconfigdistributedhardware_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourcehandlerconfigdistributedhardware_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/:distributedhardwarefwksvr_impl",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceHandlerConfigDistributedHardwareFuzzTest\"",
|
||||
"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 = [ ":SourceHandlerConfigDistributedHardwareFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 "sourcehandlerconfigdistributedhardware_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_source_handler.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "component_enable.h"
|
||||
#include "component_disable.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceHandlerConfigDistributedHardwareFuzzTest(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);
|
||||
|
||||
DCameraSourceHandler::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::SourceHandlerConfigDistributedHardwareFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+21
@@ -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 SOURCEHANDLERCONFIGDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
#define SOURCEHANDLERCONFIGDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourcehandlerconfigdistributedhardware_fuzzer"
|
||||
|
||||
#endif
|
||||
+11
-14
@@ -18,18 +18,13 @@ import(
|
||||
"//foundation/distributedhardware/distributed_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") {
|
||||
module_out_path = "distributed_camera/dcamerasinkhandleripc"
|
||||
ohos_fuzztest("SourceHandlerInitSourceFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourcehandlerinitsource"
|
||||
|
||||
fuzz_config_file =
|
||||
"${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkhandleripc_fuzzer"
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourcehandlerinitsource_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${fwk_utils_path}/include",
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
@@ -37,7 +32,9 @@ ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") {
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_sink/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -47,22 +44,22 @@ ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dcamera_sink_handler_ipc_fuzzer.cpp" ]
|
||||
sources = [ "sourcehandlerinitsource_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/:distributedhardwarefwksvr_impl",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraSinkHandlerIpcFuzzTest\"",
|
||||
"DH_LOG_TAG=\"SourceHandlerInitSourceFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
@@ -73,6 +70,6 @@ ohos_fuzztest("DCameraSinkHandlerIpcFuzzTest") {
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DCameraSinkHandlerIpcFuzzTest" ]
|
||||
deps = [ ":SourceHandlerInitSourceFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 "sourcehandlerinitsource_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_source_handler.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "component_enable.h"
|
||||
#include "component_disable.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceHandlerInitSourceFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < 0)) {
|
||||
return;
|
||||
}
|
||||
std::string params(reinterpret_cast<const char*>(data), size);
|
||||
|
||||
DCameraSourceHandler::GetInstance().InitSource(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DistributedHardware::SourceHandlerInitSourceFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-4
@@ -13,10 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DCAMERA_SINK_LOAD_CALLBACK_FUZZER_H
|
||||
#define DCAMERA_SINK_LOAD_CALLBACK_FUZZER_H
|
||||
#ifndef SOURCEHANDLERINITSOURCE_FUZZER_H
|
||||
#define SOURCEHANDLERINITSOURCE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dcamera_sink_load_callback_fuzzer"
|
||||
#define FUZZ_PROJECT_NAME "sourcehandlerinitsource_fuzzer"
|
||||
|
||||
#endif
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
# Copyright (c) 2021 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceHandlerRegisterDistributedHardwareFuzzTest") {
|
||||
module_out_path =
|
||||
"distributed_camera/sourcehandlerregisterdistributedhardware"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourcehandlerregisterdistributedhardware_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourcehandlerregisterdistributedhardware_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/:distributedhardwarefwksvr_impl",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceHandlerRegisterDistributedHardwareFuzzTest\"",
|
||||
"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 = [ ":SourceHandlerRegisterDistributedHardwareFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 "sourcehandlerregisterdistributedhardware_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_source_handler.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "component_enable.h"
|
||||
#include "component_disable.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceHandlerRegisterDistributedHardwareFuzzTest(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>();
|
||||
|
||||
DCameraSourceHandler::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::SourceHandlerRegisterDistributedHardwareFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+21
@@ -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 SOURCEHANDLERREGITSERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
#define SOURCEHANDLERREGITSERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourcehandlerregisterdistributedhardware_fuzzer "
|
||||
|
||||
#endif
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
# Copyright (c) 2021 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceHandlerUnregisterDistributedHardwareFuzzTest") {
|
||||
module_out_path =
|
||||
"distributed_camera/sourcehandlerunregisterdistributedhardware"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourcehandlerunregisterdistributedhardware_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/include/componentmanager",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourcehandlerunregisterdistributedhardware_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_services_path}/distributedhardwarefwkserviceimpl/:distributedhardwarefwksvr_impl",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceHandlerUnregisterDistributedHardwareFuzzTest\"",
|
||||
"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 = [ ":SourceHandlerUnregisterDistributedHardwareFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+52
@@ -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 "sourcehandlerunregisterdistributedhardware_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_source_handler.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "component_enable.h"
|
||||
#include "component_disable.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "refbase.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceHandlerUnregisterDistributedHardwareFuzzTest(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>();
|
||||
|
||||
DCameraSourceHandler::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::SourceHandlerUnregisterDistributedHardwareFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+21
@@ -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 SOURCEHANDLERUNREGITSERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
#define SOURCEHANDLERUNREGITSERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourcehandlerunregisterdistributedhardware_fuzzer "
|
||||
|
||||
#endif
|
||||
+6
-6
@@ -18,10 +18,10 @@ import(
|
||||
"//foundation/distributedhardware/distributed_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DCameraSourceLoadCallbackFuzzTest") {
|
||||
module_out_path = "distributed_camera/dcamerasourceloadcallback"
|
||||
ohos_fuzztest("SourceOnLoadSystemAbilityFailFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourceonloadsystemabilityfail"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasourceloadcallback_fuzzer"
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourceonloadsystemabilityfail_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
@@ -43,7 +43,7 @@ ohos_fuzztest("DCameraSourceLoadCallbackFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dcamera_source_load_callback_fuzzer.cpp" ]
|
||||
sources = [ "sourceonloadsystemabilityfail_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
@@ -53,7 +53,7 @@ ohos_fuzztest("DCameraSourceLoadCallbackFuzzTest") {
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraSourceLoadCallbackFuzzTest\"",
|
||||
"DH_LOG_TAG=\"SourceOnLoadSystemAbilityFailFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
@@ -68,6 +68,6 @@ ohos_fuzztest("DCameraSourceLoadCallbackFuzzTest") {
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DCameraSourceLoadCallbackFuzzTest" ]
|
||||
deps = [ ":SourceOnLoadSystemAbilityFailFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+6
-11
@@ -13,33 +13,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dcamera_sink_load_callback_fuzzer.h"
|
||||
#include "sourceonloadsystemabilityfail_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_sink_load_callback.h"
|
||||
#include "dcamera_sink_handler.h"
|
||||
#include "dcamera_source_load_callback.h"
|
||||
#include "dcamera_source_handler.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DCameraSinkLoadCallbackFuzzTest(const uint8_t* data, size_t size)
|
||||
void SourceOnLoadSystemAbilityFailFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < (sizeof(int32_t)))) {
|
||||
return;
|
||||
}
|
||||
int32_t systemAbilityId = *(reinterpret_cast<const int32_t *>(data));
|
||||
std::string params(reinterpret_cast<const char*>(data), size);
|
||||
std::shared_ptr<DCameraSinkLoadCallback> callback = std::make_shared<DCameraSinkLoadCallback>(params);
|
||||
std::shared_ptr<DCameraSourceLoadCallback> callback = std::make_shared<DCameraSourceLoadCallback>(params);
|
||||
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID);
|
||||
|
||||
callback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject);
|
||||
callback->OnLoadSystemAbilityFail(systemAbilityId);
|
||||
}
|
||||
}
|
||||
@@ -49,6 +44,6 @@ void DCameraSinkLoadCallbackFuzzTest(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::DCameraSinkLoadCallbackFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::SourceOnLoadSystemAbilityFailFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 SOURCEONLOADSYSTEMABLITYFAIL_FUZZER_H
|
||||
#define SOURCEONLOADSYSTEMABLITYFAIL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourceonloadsystemabilityfail_fuzzer"
|
||||
|
||||
#endif
|
||||
|
||||
+9
-8
@@ -18,13 +18,14 @@ import(
|
||||
"//foundation/distributedhardware/distributed_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DCameraSinkLoadCallbackFuzzTest") {
|
||||
module_out_path = "distributed_camera/dcamerasinkloadcallback"
|
||||
ohos_fuzztest("SourceOnLoadSystemAbilitySuccessFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourceonloadsystemabilitysuccess"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkloadcallback_fuzzer"
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourceonloadsystemabilitysuccess_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
@@ -32,7 +33,7 @@ ohos_fuzztest("DCameraSinkLoadCallbackFuzzTest") {
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_sink/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -42,17 +43,17 @@ ohos_fuzztest("DCameraSinkLoadCallbackFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dcamera_sink_load_callback_fuzzer.cpp" ]
|
||||
sources = [ "sourceonloadsystemabilitysuccess_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraSinkLoadCallbackFuzzTest\"",
|
||||
"DH_LOG_TAG=\"SourceOnLoadSystemAbilitySuccessFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
@@ -67,6 +68,6 @@ ohos_fuzztest("DCameraSinkLoadCallbackFuzzTest") {
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DCameraSinkLoadCallbackFuzzTest" ]
|
||||
deps = [ ":SourceOnLoadSystemAbilitySuccessFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+5
-7
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dcamera_source_load_callback_fuzzer.h"
|
||||
#include "sourceonloadsystemabilitysuccess_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DCameraSourceLoadCallbackFuzzTest(const uint8_t* data, size_t size)
|
||||
void SourceOnLoadSystemAbilitySuccessFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < (sizeof(int32_t)))) {
|
||||
return;
|
||||
@@ -37,10 +37,9 @@ void DCameraSourceLoadCallbackFuzzTest(const uint8_t* data, size_t size)
|
||||
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(systemAbilityId);
|
||||
|
||||
callback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject);
|
||||
callback->OnLoadSystemAbilityFail(systemAbilityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +48,6 @@ void DCameraSourceLoadCallbackFuzzTest(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::DCameraSourceLoadCallbackFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::SourceOnLoadSystemAbilitySuccessFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 SOURCEONLOADSYSTEMABLITYSUCESS_FUZZER_H
|
||||
#define SOURCEONLOADSYSTEMABLITYSUCESS_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourceonloadsystemabilitysuccess_fuzzer"
|
||||
|
||||
#endif
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
# 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceProxyDCameraNotifyFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourceproxydcameranotify"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourceproxydcameranotify_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourceproxydcameranotify_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${common_path}:distributed_camera_utils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceProxyDCameraNotifyFuzzTest\"",
|
||||
"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 = [ ":SourceProxyDCameraNotifyFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+17
-24
@@ -13,47 +13,40 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dcamera_sink_proxy_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "sourceproxydcameranotify_fuzzer.h"
|
||||
|
||||
#include "dcamera_source_callback.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_sink_proxy.h"
|
||||
#include "distributed_camera_source_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DCameraSinkProxyFuzzTest(const uint8_t* data, size_t size)
|
||||
void SourceProxyDCameraNotifyFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string param(reinterpret_cast<const char*>(data), size);
|
||||
std::string dhId(reinterpret_cast<const char*>(data), size);
|
||||
std::string params(reinterpret_cast<const char*>(data), size);
|
||||
std::string devId(reinterpret_cast<const char*>(data), size);
|
||||
std::string channelInfo(reinterpret_cast<const char*>(data), size);
|
||||
std::string cameraInfo(reinterpret_cast<const char*>(data), size);
|
||||
std::string openInfo(reinterpret_cast<const char*>(data), size);
|
||||
std::string reqId(reinterpret_cast<const char*>(data), size);
|
||||
std::string events(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;
|
||||
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID);
|
||||
std::shared_ptr<DistributedCameraSinkProxy> dCSinkProxy =
|
||||
std::make_shared<DistributedCameraSinkProxy>(remoteObject);
|
||||
|
||||
dCSinkProxy->InitSink(param);
|
||||
dCSinkProxy->SubscribeLocalHardware(dhId, params);
|
||||
dCSinkProxy->ChannelNeg(dhId, channelInfo);
|
||||
dCSinkProxy->GetCameraInfo(dhId, cameraInfo);
|
||||
dCSinkProxy->OpenChannel(dhId, openInfo);
|
||||
dCSinkProxy->CloseChannel(dhId);
|
||||
dCSinkProxy->UnsubscribeLocalHardware(dhId);
|
||||
dCSinkProxy->StopCapture(dhId);
|
||||
dCSinkProxy->ReleaseSink();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
std::shared_ptr<DistributedCameraSourceProxy> dCSourceProxy =
|
||||
std::make_shared<DistributedCameraSourceProxy>(remoteObject);
|
||||
sptr<IDCameraSourceCallback> callback = new DCameraSourceCallback();
|
||||
dCSourceProxy->DCameraNotify(devId, dhId, events);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +55,7 @@ void DCameraSinkProxyFuzzTest(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::DCameraSinkProxyFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::SourceProxyDCameraNotifyFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DCAMERA_SINK_HANDLER_IPC_FUZZER_H
|
||||
#define DCAMERA_SINK_HANDLER_IPC_FUZZER_H
|
||||
#ifndef SOURCEPROXYDCAMERANOTIFY_FUZZER_H
|
||||
#define SOURCEPROXYDCAMERANOTIFY_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dcamera_sink_handler_ipc_fuzzer"
|
||||
#define FUZZ_PROJECT_NAME "sourceproxydcameranotify_fuzzer"
|
||||
|
||||
#endif
|
||||
+10
-9
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@@ -18,14 +18,15 @@ import(
|
||||
"//foundation/distributedhardware/distributed_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("DCameraSinkProxyFuzzTest") {
|
||||
module_out_path = "distributed_camera/dcamerasinkproxy"
|
||||
ohos_fuzztest("SourceProxyInitSourceFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourceproxyinitsource"
|
||||
|
||||
fuzz_config_file =
|
||||
"${innerkits_path}/native_cpp/test/fuzztest/dcamerasinkproxy_fuzzer"
|
||||
"${innerkits_path}/native_cpp/test/fuzztest/sourceproxyinitsource_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
@@ -33,7 +34,7 @@ ohos_fuzztest("DCameraSinkProxyFuzzTest") {
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_sink/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
@@ -43,17 +44,17 @@ ohos_fuzztest("DCameraSinkProxyFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "dcamera_sink_proxy_fuzzer.cpp" ]
|
||||
sources = [ "sourceproxyinitsource_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${common_path}:distributed_camera_utils",
|
||||
"${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"DCameraSinkProxyFuzzTest\"",
|
||||
"DH_LOG_TAG=\"SourceProxyInitSourceFuzzTest\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
@@ -68,6 +69,6 @@ ohos_fuzztest("DCameraSinkProxyFuzzTest") {
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DCameraSinkProxyFuzzTest" ]
|
||||
deps = [ ":SourceProxyInitSourceFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+11
-14
@@ -13,34 +13,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dcamera_sink_handler_ipc_fuzzer.h"
|
||||
#include "sourceproxyinitsource_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dcamera_sink_handler.h"
|
||||
#include "dcamera_sink_handler_ipc.h"
|
||||
#include "dcamera_source_callback.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_source_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DCameraSinkHandlerIpcFuzzTest(const uint8_t* data, size_t size)
|
||||
void SourceProxyInitSourceFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size <= 0)) {
|
||||
return;
|
||||
}
|
||||
std::string params(reinterpret_cast<const char*>(data), size);
|
||||
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID);
|
||||
wptr<IRemoteObject> remote (remoteObject);
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
std::shared_ptr<DistributedCameraSourceProxy> dCSourceProxy =
|
||||
std::make_shared<DistributedCameraSourceProxy>(remoteObject);
|
||||
sptr<IDCameraSourceCallback> callback = new DCameraSourceCallback();
|
||||
|
||||
DCameraSinkHandlerIpc::GetInstance().Init();
|
||||
DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS();
|
||||
DCameraSinkHandlerIpc::GetInstance().OnSinkLocalDmsDied(remote);
|
||||
DCameraSinkHandlerIpc::GetInstance().UnInit();
|
||||
dCSourceProxy->InitSource(params, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +46,7 @@ void DCameraSinkHandlerIpcFuzzTest(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::DCameraSinkHandlerIpcFuzzTest(data, size);
|
||||
OHOS::DistributedHardware::SourceProxyInitSourceFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H
|
||||
#define DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H
|
||||
#ifndef SOURCEPROXYINITSOURCE_FUZZER_H
|
||||
#define SOURCEPROXYINITSOURCE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dcamera_source_handler_ipc_fuzzer"
|
||||
#define FUZZ_PROJECT_NAME "sourceproxyinitsource_fuzzer"
|
||||
|
||||
#endif
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
# 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceProxyRegisterDistributedHardwareFuzzTest") {
|
||||
module_out_path = "distributed_camera/sourceproxyregisterdistributedhardware"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourceproxyregisterdistributedhardware_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourceproxyregisterdistributedhardware_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${common_path}:distributed_camera_utils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceProxyRegisterDistributedHardwareFuzzTest\"",
|
||||
"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 = [ ":SourceProxyRegisterDistributedHardwareFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 "sourceproxyregisterdistributedhardware_fuzzer.h"
|
||||
|
||||
#include "dcamera_source_callback.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_source_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceProxyRegisterDistributedHardwareFuzzTest(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);
|
||||
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;
|
||||
|
||||
sptr<ISystemAbilityManager> samgr =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
std::shared_ptr<DistributedCameraSourceProxy> dCSourceProxy =
|
||||
std::make_shared<DistributedCameraSourceProxy>(remoteObject);
|
||||
sptr<IDCameraSourceCallback> callback = new DCameraSourceCallback();
|
||||
|
||||
dCSourceProxy->RegisterDistributedHardware(devId, dhId, reqId, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::DistributedHardware::SourceProxyRegisterDistributedHardwareFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H
|
||||
#define DCAMERA_SOURCE_HANDLER_IPC_FUZZER_H
|
||||
#ifndef SOURCEPROXYREGISTERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
#define SOURCEPROXYREGISTERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dcamera_source_load_callback_fuzzer"
|
||||
#define FUZZ_PROJECT_NAME "sourceproxyregisterdistributedhardware_fuzzer"
|
||||
|
||||
#endif
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
# 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_camera/distributedcamera.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("SourceProxyUnregisterDistributedHardwareFuzzTest") {
|
||||
module_out_path =
|
||||
"distributed_camera/sourceproxyunregisterdistributedhardware"
|
||||
|
||||
fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sourceproxyunregisterdistributedhardware_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"${innerkits_path}/native_cpp/camera_source/include/callback",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/constants",
|
||||
"${innerkits_path}/native_cpp/camera_source/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "sourceproxyunregisterdistributedhardware_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${common_path}:distributed_camera_utils",
|
||||
"${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"SourceProxyUnregisterDistributedHardwareFuzzTest\"",
|
||||
"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 = [ ":SourceProxyUnregisterDistributedHardwareFuzzTest" ]
|
||||
}
|
||||
###############################################################################
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
# 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
|
||||
+25
@@ -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>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 "sourceproxyunregisterdistributedhardware_fuzzer.h"
|
||||
|
||||
#include "dcamera_source_callback.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_source_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void SourceProxyUnregisterDistributedHardwareFuzzTest(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();
|
||||
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID);
|
||||
std::shared_ptr<DistributedCameraSourceProxy> dCSourceProxy =
|
||||
std::make_shared<DistributedCameraSourceProxy>(remoteObject);
|
||||
|
||||
dCSourceProxy->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::SourceProxyUnregisterDistributedHardwareFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+21
@@ -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 SOURCEPROXYUNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
#define SOURCEPROXYUNREGISTERDISTRIBUTEDHARDWARE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "sourceproxyunregisterdistributedhardware_fuzzer"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user