diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn index f8fb00a9f92869464c0416a3731c2138769ac30b..8a6f83140fe4b165b05ae71c50368acc8d62a486 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn @@ -22,6 +22,14 @@ group("fuzztest") { "sinkhandlerunsubscribelocalhardware_fuzzer:fuzztest", "sinkonloadsystemabilityfail_fuzzer:fuzztest", "sinkonloadsystemabilitysuccess_fuzzer:fuzztest", + "sinkproxychannelneg_fuzzer:fuzztest", + "sinkproxyclosechannel_fuzzer:fuzztest", + "sinkproxygetcamerainfo_fuzzer:fuzztest", + "sinkproxyinitsink_fuzzer:fuzztest", + "sinkproxyopenchannel_fuzzer:fuzztest", + "sinkproxystopcapture_fuzzer:fuzztest", + "sinkproxysubscribelocalhardware_fuzzer:fuzztest", + "sinkproxyunsubscribelocalhardware_fuzzer:fuzztest", "sourcehandlerconfigdistributedhardware_fuzzer:fuzztest", "sourcehandlerinitsource_fuzzer:fuzztest", "sourcehandlerregisterdistributedhardware_fuzzer:fuzztest", diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/onsourcelocaldmsdied_fuzzer/onsourcelocaldmsdied_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/onsourcelocaldmsdied_fuzzer/onsourcelocaldmsdied_fuzzer.cpp index 11ab8dcfb2ca6638b4657efc21198b6893b9de28..c7bd3d6bf9c2f95fce9b37eb10fe70251afa7a70 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/onsourcelocaldmsdied_fuzzer/onsourcelocaldmsdied_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/onsourcelocaldmsdied_fuzzer/onsourcelocaldmsdied_fuzzer.cpp @@ -28,7 +28,7 @@ namespace OHOS { namespace DistributedHardware { void OnSourceLocalDmsDiedFuzzTest(const uint8_t* data, size_t size) { - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size < (sizeof(int32_t)))) { return; } diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0ccfeaf98db448bb0c1564fab34af50d413cbbb1 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/BUILD.gn @@ -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("SinkProxyChannelNegFuzzTest") { + module_out_path = "distributed_camera/sinkproxychannelneg" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxychannelneg_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxychannelneg_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyChannelNegFuzzTest\"", + "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 = [ ":SinkProxyChannelNegFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..309e90c0cb2420d7362a976bc644176f31ec6d73 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "sinkproxychannelneg_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyChannelNegFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + std::string channelInfo(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->ChannelNeg(dhId, channelInfo); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyChannelNegFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..296d13ab4cb7fbb84833d82acd4dde57bc2c5283 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYCHANNELNEG_FUZZER_H +#define SINKPROXYCHANNELNEG_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxychannelneg_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f1f82eafae6907b873dc79b7fbcd2c612632a4d8 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/BUILD.gn @@ -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("SinkProxyCloseChannelFuzzTest") { + module_out_path = "distributed_camera/sinkproxyclosechannel" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxyclosechannel_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxyclosechannel_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyCloseChannelFuzzTest\"", + "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 = [ ":SinkProxyCloseChannelFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c883540f630a453509b526140882d6053142ccc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp @@ -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 "sinkproxyclosechannel_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyCloseChannelFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + std::string dhId(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->CloseChannel(dhId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyCloseChannelFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b6380e00a3e3db27bff2636179cd9bc426efbc7d --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYCLOSECHANNEL_FUZZER_H +#define SINKPROXYCLOSECHANNEL_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxyclosechannel_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5cc5197dce1c873b492475754174c6eb488e8e17 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/BUILD.gn @@ -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("SinkProxyGetCameraInfoFuzzTest") { + module_out_path = "distributed_camera/sinkproxygetcamerainfo" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxygetcamerainfo_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxygetcamerainfo_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyGetCameraInfoFuzzTest\"", + "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 = [ ":SinkProxyGetCameraInfoFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..797fe39f20f49ad4c227080e6735c40dc5690747 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "sinkproxygetcamerainfo_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyGetCameraInfoFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + std::string cameraInfo(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->GetCameraInfo(dhId, cameraInfo); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyGetCameraInfoFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..3b3f4abdebad220a57323f8dde4beabd9c16ac30 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYGETCAMERAINFO_FUZZER_H +#define SINKPROXYGETCAMERAINFO_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxygetcamerainfo_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f05f7333c7eb9264f565751c0569432f037613d0 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/BUILD.gn @@ -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("SinkProxyInitSinkFuzzTest") { + module_out_path = "distributed_camera/sinkproxyinitsink" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxyinitsink_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxyinitsink_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyInitSinkFuzzTest\"", + "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 = [ ":SinkProxyInitSinkFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..654ba78b1219fc476b8933ac17b6471b96d4604e --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp @@ -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 "sinkproxyinitsink_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyInitSinkFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string param(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->InitSink(param); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyInitSinkFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..97d8560b2b9405cbabeb72fda4b5711e7dc6b364 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYINITSINK_FUZZER_H +#define SINKPROXYINITSINK_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxyinitsink_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..42bab4e1bff3169bd225bba83a28947b5392bd1d --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/BUILD.gn @@ -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("SinkProxyOpenChannelFuzzTest") { + module_out_path = "distributed_camera/sinkproxyopenchannel" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxyopenchannel_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxyopenchannel_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyOpenChannelFuzzTest\"", + "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 = [ ":SinkProxyOpenChannelFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..db26ef0f3556ce6f2e5eb614e50d9dbc41b6c4b2 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "sinkproxyopenchannel_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyOpenChannelFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + std::string openInfo(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->OpenChannel(dhId, openInfo); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyOpenChannelFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..079473ae07eedc9fc641a7fb1c60d56d8da7dcd2 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYOPENCHANNEL_FUZZER_H +#define SINKPROXYOPENCHANNEL_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxyopenchannel_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..59a190170daed706bfc70624b20a6489de0a091d --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/BUILD.gn @@ -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("SinkProxyStopCaptureFuzzTest") { + module_out_path = "distributed_camera/sinkproxystopcapture" + + fuzz_config_file = + "${innerkits_path}/native_cpp/test/fuzztest/sinkproxystopcapture_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxystopcapture_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyStopCaptureFuzzTest\"", + "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 = [ ":SinkProxyStopCaptureFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4439c4b08d765c9f7f61f13ddf0cac1a8b276e4c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp @@ -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 "sinkproxystopcapture_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyStopCaptureFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->StopCapture(dhId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyStopCaptureFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..67eff92da34c47927e8f35cb8732b8f93e1a7e24 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYSTOPCAPTURE_FUZZER_H +#define SINKPROXYSTOPCAPTURE_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxystopcapture_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..198e8549a71fe82a87a7559aa395934fd4884df4 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/BUILD.gn @@ -0,0 +1,72 @@ +# 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("SinkProxySubscribeLocalHardwareFuzzTest") { + module_out_path = "distributed_camera/sinkproxysubscribelocalhardware" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxysubscribelocalhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxySubscribeLocalHardwareFuzzTest\"", + "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 = [ ":SinkProxySubscribeLocalHardwareFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..715312ae6b381f50016989bbd970558fa550841a --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "sinkproxysubscribelocalhardware_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxySubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string params(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->SubscribeLocalHardware(dhId, params); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxySubscribeLocalHardwareFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e2ee840b7033afd43065b56a3531676fa4cbb4e7 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYSUBSCRIBELOCALHARDWARE_FUZZER_H +#define SINKPROXYSUBSCRIBELOCALHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxysubscribelocalhardware_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5046b3162684b3bfd011175c3cdaf68f97bf19be --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/BUILD.gn @@ -0,0 +1,72 @@ +# 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("SinkProxyUnsubscribeLocalHardwareFuzzTest") { + module_out_path = "distributed_camera/sinkproxyunsubscribelocalhardware" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_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_sink/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "sinkproxyunsubscribelocalhardware_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk", + "//utils/native/base:utils", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SinkProxyUnsubscribeLocalHardwareFuzzTest\"", + "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 = [ ":SinkProxyUnsubscribeLocalHardwareFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/corpus/init @@ -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 \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..982e56d1055d578a9360fb5946764c293340457a --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp @@ -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 "sinkproxyunsubscribelocalhardware_fuzzer.h" + +#include +#include + +#include "distributed_camera_constants.h" +#include "distributed_camera_sink_proxy.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +namespace OHOS { +namespace DistributedHardware { +void SinkProxyUnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size <= 0)) { + return; + } + + std::string dhId(reinterpret_cast(data), size); + + sptr samgr = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); + std::shared_ptr dCSinkProxy = + std::make_shared(remoteObject); + + dCSinkProxy->UnsubscribeLocalHardware(dhId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SinkProxyUnsubscribeLocalHardwareFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..50b08875bb2f5da6f1e14c320bbcb58353e575c8 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SINKPROXYUNSUBSRCRIBELOCALHARDWARE_FUZZER_H +#define SINKPROXYUNSUBSRCRIBELOCALHARDWARE_FUZZER_H + +#define FUZZ_PROJECT_NAME "sinkproxyunsubscribelocalhardware_fuzzer " + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp index 22cf7e128c0a211187db86af45f63769458d2a0e..ecc11335245c04725cbaad24725b60ed9531d0a9 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp @@ -30,15 +30,8 @@ void SourceProxyDCameraNotifyFuzzTest(const uint8_t* data, size_t size) } std::string dhId(reinterpret_cast(data), size); - std::string params(reinterpret_cast(data), size); std::string devId(reinterpret_cast(data), size); - std::string reqId(reinterpret_cast(data), size); std::string events(reinterpret_cast(data), size); - std::string version(reinterpret_cast(data), size); - std::string attrs(reinterpret_cast(data), size); - EnableParam param; - param.version = version; - param.attrs = attrs; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();