diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/BUILD.gn
index aa4e576f09a28190bc878d4b50fb7c5df18b99b1..ffaf01390eca6dd1e153b1f8ba5bc8778b8c54f6 100644
--- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/BUILD.gn
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
+# Copyright (c) 2025 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
@@ -42,6 +42,8 @@ group("fuzztest") {
"sinkservicechannelneg_fuzzer:fuzztest",
"sinkserviceclosechannel_fuzzer:fuzztest",
"sinkservicegetcamerainfo_fuzzer:fuzztest",
+ "sinkservicedump_fuzzer:fuzztest",
+ "sinkservicegetdumpinfo_fuzzer:fuzztest",
"sinkserviceinitsink_fuzzer:fuzztest",
"sinkserviceopenchannel_fuzzer:fuzztest",
"sinkservicepausedistributedhardware_fuzzer:fuzztest",
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..e858fee9e8f11257a9c737208b53cedaa5c44cb2
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/BUILD.gn
@@ -0,0 +1,86 @@
+# Copyright (c) 2025 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("SinkServiceDumpFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/sinkservicedump"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer"
+
+ include_dirs = [
+ "include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${innerkits_path}/native_cpp/camera_sink/include",
+ "${innerkits_path}/native_cpp/camera_sink/include/callback",
+ "${services_path}/cameraservice/base/include",
+ "${services_path}/cameraservice/cameraoperator/client/include",
+ "${services_path}/cameraservice/sinkservice/include/distributedcamera",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr/interface",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr/eventbus",
+ "${services_path}/data_process/include/utils",
+ "${services_path}/channel/include",
+ "${feeding_smoother_path}/base",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
+ ]
+
+ sources = [ "sinkservicedump_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk",
+ "${services_path}/cameraservice/sinkservice:distributed_camera_sink",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SinkServiceDumpFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "cJSON:cjson",
+ "c_utils:utils",
+ "device_manager:devicemanagersdk",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1",
+ "eventhandler:libeventhandler",
+ "graphic_surface:surface",
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SinkServiceDumpFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2025 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/sinkfuzztest/sinkservicedump_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..744af481e3244754af61739786c1acacbc14aab5
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 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 "sinkservicedump_fuzzer.h"
+#include "distributed_camera_sink_service.h"
+#include "distributed_camera_constants.h"
+#include
+#include
+#include
+#include
+
+namespace OHOS {
+namespace DistributedHardware {
+void SinkServiceDumpFuzzTest(const uint8_t* data, size_t size)
+{
+ if (data == nullptr || size == 0) {
+ return;
+ }
+ auto sinkService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
+
+ std::vector args;
+ std::u16string arg(reinterpret_cast(data), size / sizeof(char16_t));
+ if (arg.empty() || std::all_of(arg.begin(), arg.end(), [](char16_t c) { return c == 0; })) {
+ return;
+ }
+ args.push_back(arg);
+ int fd = STDOUT_FILENO;
+
+ sinkService->Dump(fd, args);
+}
+}
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SinkServiceDumpFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..92c28c06cb8cb523903b29402910116c0986c8a1
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicedump_fuzzer/sinkservicedump_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 SINKSERVICEDUMP_FUZZER_H
+#define SINKSERVICEDUMP_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sinkservicedump_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..fb0a7ffecf3595dc5d1e24071dd1de17299b0f82
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/BUILD.gn
@@ -0,0 +1,86 @@
+# Copyright (c) 2025 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("SinkServiceGetDumpInfoFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/sinkservicegetdumpinfo"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer"
+
+ include_dirs = [
+ "include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${innerkits_path}/native_cpp/camera_sink/include",
+ "${innerkits_path}/native_cpp/camera_sink/include/callback",
+ "${services_path}/cameraservice/base/include",
+ "${services_path}/cameraservice/cameraoperator/client/include",
+ "${services_path}/cameraservice/sinkservice/include/distributedcamera",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr/interface",
+ "${services_path}/cameraservice/sinkservice/include/distributedcameramgr/eventbus",
+ "${services_path}/data_process/include/utils",
+ "${services_path}/channel/include",
+ "${feeding_smoother_path}/base",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
+ ]
+
+ sources = [ "sinkservicegetdumpinfo_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${innerkits_path}/native_cpp/camera_sink:distributed_camera_sink_sdk",
+ "${services_path}/cameraservice/sinkservice:distributed_camera_sink",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SinkServiceGetDumpInfoFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "cJSON:cjson",
+ "c_utils:utils",
+ "device_manager:devicemanagersdk",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1",
+ "eventhandler:libeventhandler",
+ "graphic_surface:surface",
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SinkServiceGetDumpInfoFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2025 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/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d05e13e26281c20379ed200e06afb6aec9a999ed
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2025 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 "sinkservicegetdumpinfo_fuzzer.h"
+#include "distributed_camera_sink_service.h"
+#include "distributed_camera_constants.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void SinkServiceGetDumpInfoFuzzTest(const uint8_t* data, size_t size)
+{
+ auto sinkService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
+
+ CameraDumpInfo camDump;
+ sinkService->GetCamDumpInfo(camDump);
+}
+}
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SinkServiceGetDumpInfoFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe97e20d0082fb2dde7a0e0c863f5a3898231868
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicegetdumpinfo_fuzzer/sinkservicegetdumpinfo_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 SINKSERVICEDUMPINFO_FUZZER_H
+#define SINKSERVICEDUMPINFO_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sinkservicedumpinfo_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkserviceinitsink_fuzzer/sinkserviceinitsink_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkserviceinitsink_fuzzer/sinkserviceinitsink_fuzzer.cpp
index 7c469e81fc813062ee01e5faa1b7440fc216b109..610a12751655925280ee9f314f3b425fc8e7a60f 100644
--- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkserviceinitsink_fuzzer/sinkserviceinitsink_fuzzer.cpp
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkserviceinitsink_fuzzer/sinkserviceinitsink_fuzzer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
+ * Copyright (c) 2023-2025 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
@@ -14,71 +14,29 @@
*/
#include "sinkserviceinitsink_fuzzer.h"
-
-#include
-#include
-
-#include "dcamera_sink_controller.h"
-#include "dcamera_sink_access_control.h"
+#include "distributed_camera_sink_service.h"
#include "dcamera_sink_callback.h"
#include "distributed_camera_constants.h"
-#include "distributed_camera_sink_service.h"
-#include "if_system_ability_manager.h"
-#include "iservice_registry.h"
namespace OHOS {
namespace DistributedHardware {
-namespace {
-const int32_t SINK_FUZZ_TEST_SLEEP = 200000;
-}
-
-std::shared_ptr sinkService_ =
- std::make_shared(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
-
-void SinkServiceOnStartFuzzTest()
-{
- sinkService_->OnStart();
-}
void SinkServiceInitSinkFuzzTest(const uint8_t* data, size_t size)
{
- if ((data == nullptr) || (size == 0)) {
+ if (data == nullptr || size == 0) {
return;
}
-
+ auto sinkService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
std::string param(reinterpret_cast(data), size);
- std::string dhId = "1";
-
- std::shared_ptr sinkService =
- std::make_shared(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
- sptr sinkCallback(new DCameraSinkCallback());
- std::shared_ptr sinkDevice = std::make_shared(dhId, sinkCallback);
- sinkDevice->accessControl_ = std::make_shared();
- sinkDevice->controller_ = std::make_shared(sinkDevice->accessControl_, sinkCallback);
- sinkService->InitSink(param, sinkCallback);
- usleep(SINK_FUZZ_TEST_SLEEP);
-}
-
-void SinkServiceReleaseSinkFuzzTest()
-{
- sinkService_->ReleaseSink();
-}
-
-void SinkServiceOnStopFuzzTest()
-{
- sinkService_->OnStop();
+ sptr callback(new DCameraSinkCallback());
+ sinkService->InitSink(param, callback);
}
}
}
-/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
- /* Run your code on data */
- OHOS::DistributedHardware::SinkServiceOnStartFuzzTest();
- OHOS::DistributedHardware::SinkServiceReleaseSinkFuzzTest();
- OHOS::DistributedHardware::SinkServiceOnStopFuzzTest();
OHOS::DistributedHardware::SinkServiceInitSinkFuzzTest(data, size);
return 0;
-}
-
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicereleasesink_fuzzer/sinkservicereleasesink_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicereleasesink_fuzzer/sinkservicereleasesink_fuzzer.cpp
index 05f4dae34310ddd266ef8c3e5fdfd7f646ddfe5d..d0d1a3b84b97e0121bbc4ea211ae3331d7d41c6b 100644
--- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicereleasesink_fuzzer/sinkservicereleasesink_fuzzer.cpp
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicereleasesink_fuzzer/sinkservicereleasesink_fuzzer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
+ * Copyright (c) 2023-2025 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
@@ -14,38 +14,28 @@
*/
#include "sinkservicereleasesink_fuzzer.h"
-
-#include
-#include
-
+#include "distributed_camera_sink_service.h"
#include "dcamera_sink_callback.h"
#include "distributed_camera_constants.h"
-#include "distributed_camera_sink_service.h"
-#include "if_system_ability_manager.h"
-#include "iservice_registry.h"
namespace OHOS {
namespace DistributedHardware {
void SinkServiceReleaseSinkFuzzTest(const uint8_t* data, size_t size)
{
- if (data == nullptr) {
- return;
- }
- std::string dhId = "1";
- std::shared_ptr sinkService =
- std::make_shared(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
- sptr sinkCallback(new DCameraSinkCallback());
- std::shared_ptr sinkDevice = std::make_shared(dhId, sinkCallback);
- sinkService->camerasMap_.emplace(dhId, sinkDevice);
+ auto sinkService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
+
+ std::string params = "fuzz_test_params";
+ sptr callback(new DCameraSinkCallback());
+ sinkService->InitSink(params, callback);
+
sinkService->ReleaseSink();
}
}
}
-/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
- /* Run your code on data */
OHOS::DistributedHardware::SinkServiceReleaseSinkFuzzTest(data, size);
return 0;
}
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicestopdistributedhardware_fuzzer/sinkservicestopdistributedhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicestopdistributedhardware_fuzzer/sinkservicestopdistributedhardware_fuzzer.cpp
index 515bc03c1b3faec2b1ee448624f8871c9aac1860..c23959b598ec9303eecefdb4bbba33932204e85a 100644
--- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicestopdistributedhardware_fuzzer/sinkservicestopdistributedhardware_fuzzer.cpp
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkservicestopdistributedhardware_fuzzer/sinkservicestopdistributedhardware_fuzzer.cpp
@@ -14,95 +14,28 @@
*/
#include "sinkservicestopdistributedhardware_fuzzer.h"
-
-#include
-#include
-
-#include "distributed_camera_constants.h"
#include "distributed_camera_sink_service.h"
-#include "if_system_ability_manager.h"
-#include "iservice_registry.h"
+#include "distributed_camera_constants.h"
namespace OHOS {
namespace DistributedHardware {
-std::shared_ptr sinkService_ =
- std::make_shared(
- DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
-
void SinkServiceStopDistributedHardwareFuzzTest(const uint8_t* data, size_t size)
{
- if ((data == nullptr) || (size == 0)) {
+ if (data == nullptr || size == 0) {
return;
}
+ auto sinkService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, true);
std::string networkId(reinterpret_cast(data), size);
- sinkService_->StopDistributedHardware(networkId);
-}
-
-void SinkServiceOnStartFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sinkService_->OnStart();
-}
-
-void DistributedCameraSinkServiceInitFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sinkService_->Init();
-}
-
-void DistributedCameraSinkServiceDumpFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- std::vector args;
- std::u16string arg(reinterpret_cast(data), size / sizeof(char16_t));
- args.push_back(arg);
- int fd = STDOUT_FILENO;
-
- sinkService_->Dump(fd, args);
-}
-
-void DistributedCameraSinkServiceGetCamDumpInfoFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- CameraDumpInfo camDump;
-
- sinkService_->GetCamDumpInfo(camDump);
-}
-
-void DistributedCameraSinkServiceOnStopFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sinkService_->OnStop();
+ sinkService->StopDistributedHardware(networkId);
}
}
}
-/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
- /* Run your code on data */
OHOS::DistributedHardware::SinkServiceStopDistributedHardwareFuzzTest(data, size);
- OHOS::DistributedHardware::SinkServiceOnStartFuzzTest(data, size);
- OHOS::DistributedHardware::DistributedCameraSinkServiceInitFuzzTest(data, size);
- OHOS::DistributedHardware::DistributedCameraSinkServiceOnStopFuzzTest(data, size);
- OHOS::DistributedHardware::DistributedCameraSinkServiceDumpFuzzTest(data, size);
- OHOS::DistributedHardware::DistributedCameraSinkServiceGetCamDumpInfoFuzzTest(data, size);
return 0;
}
diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/softbusonsinkstreamreceived_fuzzer/corpus/01 b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/softbusonsinkstreamreceived_fuzzer/corpus/01
new file mode 100644
index 0000000000000000000000000000000000000000..27bce764db998325cf208a0e037b3f42a76e1cd0
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/softbusonsinkstreamreceived_fuzzer/corpus/01
@@ -0,0 +1,16 @@
+# Copyright (c) 2023 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.
+
+01 00 00 00 00 00 00 00 00 28 6B 8B B4 61 06 00
+65 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/BUILD.gn
index 9f8b5cd8720c0c0077850613659e8aa4aab8a9fb..16732bb59a55bb3eefd446bc15bfd6f038c63689 100644
--- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/BUILD.gn
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 - 2023 Huawei Device Co., Ltd.
+# Copyright (c) 2022 - 2025 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
@@ -27,6 +27,7 @@ group("fuzztest") {
"softbusonsourcesessionclosed_fuzzer:fuzztest",
"softbusonsourcesessionopened_fuzzer:fuzztest",
"softbusonsourcestreamreceived_fuzzer:fuzztest",
+ "softbushandlesourcestreamext_fuzzer:fuzztest",
"sourcehandlerconfigdistributedhardware_fuzzer:fuzztest",
"sourcehandlerinitsource_fuzzer:fuzztest",
"sourcehandlerregisterdistributedhardware_fuzzer:fuzztest",
@@ -38,7 +39,9 @@ group("fuzztest") {
"sourceproxyregisterdistributedhardware_fuzzer:fuzztest",
"sourceproxyunregisterdistributedhardware_fuzzer:fuzztest",
"sourceservicedcameranotify_fuzzer:fuzztest",
- "sourceserviceinitsource_fuzzer:fuzztest",
+ "sourceservicedump_fuzzer:fuzztest",
+ "sourceservicegetdumpinfo_fuzzer:fuzztest",
+ "sourceservicecamdeverase_fuzzer:fuzztest",
"sourceserviceregisterdistributedhardware_fuzzer:fuzztest",
"sourceservicereleasesource_fuzzer:fuzztest",
"sourceserviceunregisterdistributedhardware_fuzzer:fuzztest",
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusadapter_fuzzer/corpus/01 b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusadapter_fuzzer/corpus/01
new file mode 100644
index 0000000000000000000000000000000000000000..b8029b1a6ffcf30f1dbac1c5e02f734a4803522a
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusadapter_fuzzer/corpus/01
@@ -0,0 +1,16 @@
+# Copyright (c) 2025 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.
+
+01 00 00 00 00 00 00 00 00 28 6B 8B B4 61 06 00
+65 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..f37228cb369b136b4929a3b16de0b8b44f467472
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/BUILD.gn
@@ -0,0 +1,74 @@
+# Copyright (c) 2023-2025 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("SoftbusHandleSourceStreamExtFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/softbushandlesourcestreamext"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer"
+
+ include_dirs = [ "${services_path}/cameraservice/base/include" ]
+
+ include_dirs += [
+ "${services_path}/channel/include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${feeding_smoother_path}/base",
+ "${feeding_smoother_path}/derived",
+ "${feeding_smoother_path}/utils",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
+ ]
+
+ sources = [ "softbushandlesourcestreamext_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${services_path}/channel:distributed_camera_channel",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SoftbusHandleSourceStreamExtFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "c_utils:utils",
+ "device_manager:devicemanagersdk",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "distributed_hardware_fwk:libdhfwk_sdk",
+ "dsoftbus:softbus_client",
+ "eventhandler:libeventhandler",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SoftbusHandleSourceStreamExtFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2023 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/sourcefuzztest/softbushandlesourcestreamext_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0f449659c956006534ccfe611d3095adef054a5d
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023 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 "softbushandlesourcestreamext_fuzzer.h"
+#include "dcamera_softbus_adapter.h"
+#include "data_buffer.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+
+void SoftbusHandleSourceStreamExtFuzzTest(const uint8_t* data, size_t size)
+{
+ if (data == nullptr || size == 0) {
+ return;
+ }
+
+ auto buffer = std::make_shared(0);
+
+ const StreamData ext = {
+ const_cast(reinterpret_cast(data)), static_cast(size)
+ };
+
+ DCameraSoftbusAdapter::GetInstance().HandleSourceStreamExt(buffer, &ext);
+}
+
+} // namespace DistributedHardware
+} // namespace OHOS
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SoftbusHandleSourceStreamExtFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..00117e9c58607b287ae35051fc8bf93273c7b34d
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbushandlesourcestreamext_fuzzer/softbushandlesourcestreamext_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2023 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 SOFTBUSHANDLESOURCESTREAMEXT_FUZZER_H
+#define SOFTBUSHANDLESOURCESTREAMEXT_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "softbushandlesourcestreamext_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusonsourcestreamreceived_fuzzer/corpus/01 b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusonsourcestreamreceived_fuzzer/corpus/01
new file mode 100644
index 0000000000000000000000000000000000000000..b8029b1a6ffcf30f1dbac1c5e02f734a4803522a
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/softbusonsourcestreamreceived_fuzzer/corpus/01
@@ -0,0 +1,16 @@
+# Copyright (c) 2025 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.
+
+01 00 00 00 00 00 00 00 00 28 6B 8B B4 61 06 00
+65 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..f9292e6a0b9e3b810feafe191e6e4e08ef970503
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/BUILD.gn
@@ -0,0 +1,88 @@
+# Copyright (c) 2023-2025 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("SourceServiceCamDevEraseFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/sourceservicecamdeverase"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer"
+
+ include_dirs =
+ [ "${innerkits_path}/native_cpp/camera_source/include/callback" ]
+
+ include_dirs += [
+ "include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${innerkits_path}/native_cpp/camera_source/include",
+ "${innerkits_path}/native_cpp/camera_source/include/callback",
+ "${services_path}/cameraservice/base/include",
+ "${services_path}/cameraservice/sourceservice/include/distributedcamera",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameradata",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerastate",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
+ ]
+
+ sources = [ "sourceservicecamdeverase_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
+ "${services_path}/cameraservice/sourceservice:distributed_camera_source",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SourceServiceCamDevEraseFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "cJSON:cjson",
+ "c_utils:utils",
+ "distributed_hardware_fwk:distributed_av_receiver",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "distributed_hardware_fwk:libdhfwk_sdk",
+ "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1",
+ "eventhandler:libeventhandler",
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SourceServiceCamDevEraseFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2025 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/sourcefuzztest/sourceservicecamdeverase_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..89ad8bc4a6e64c352e2a6ee4726c045bb11e3eca
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2025 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 "sourceservicecamdeverase_fuzzer.h"
+#include "distributed_camera_source_service.h"
+#include "distributed_camera_constants.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+
+inline std::string ExtractString(const uint8_t* data, size_t offset, size_t length)
+{
+ return std::string(reinterpret_cast(data + offset), length);
+}
+
+void SourceServiceCamDevEraseFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(DCameraIndex))) {
+ return;
+ }
+
+ auto sourceService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, true);
+
+ int doubleNum = 2;
+ DCameraIndex index;
+ index.devId_ = ExtractString(data, 0, size / doubleNum);
+ index.dhId_ = ExtractString(data, size / doubleNum, size / doubleNum);
+
+ sourceService->CamDevErase(index);
+}
+
+} // namespace DistributedHardware
+} // namespace OHOS
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SourceServiceCamDevEraseFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..10b1c9606f2957993ca60e70f2a38b7afd0ec27a
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicecamdeverase_fuzzer/sourceservicecamdeverase_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 SOURCESERVICECAMDEVERASE_FUZZER_H
+#define SOURCESERVICECAMDEVERASE_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sourceservicecamdeverase_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedcameranotify_fuzzer/sourceservicedcameranotify_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedcameranotify_fuzzer/sourceservicedcameranotify_fuzzer.cpp
index bbdcd22d6234eb5f5b191dab6df2c4c0f02968ff..5f391e054a33986a1173f657d1b94210c7101ca8 100644
--- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedcameranotify_fuzzer/sourceservicedcameranotify_fuzzer.cpp
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedcameranotify_fuzzer/sourceservicedcameranotify_fuzzer.cpp
@@ -14,116 +14,34 @@
*/
#include "sourceservicedcameranotify_fuzzer.h"
-
-#include "dcamera_source_callback.h"
-#include "distributed_camera_constants.h"
#include "distributed_camera_source_service.h"
-#include "if_system_ability_manager.h"
-#include "iservice_registry.h"
+#include "distributed_camera_constants.h"
namespace OHOS {
-inline std::string ExtractString(const uint8_t* data, size_t offset, size_t length)
-{
- return std::string(reinterpret_cast(data + offset), length);
-}
namespace DistributedHardware {
-std::shared_ptr sourceService_ =
- std::make_shared(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, true);
+
void SourceServiceDCameraNotifyFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size == 0)) {
return;
}
+ auto sourceService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, true);
+
std::string dhId(reinterpret_cast(data), size);
std::string devId(reinterpret_cast(data), size);
std::string events(reinterpret_cast(data), size);
- sourceService_->DCameraNotify(devId, dhId, events);
-}
-
-void SourceServiceOnStartFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sourceService_->OnStart();
-}
-
-void SourceServiceInitFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sourceService_->Init();
-}
-
-void SourceServiceOnStopFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- sourceService_->OnStop();
+ sourceService->DCameraNotify(devId, dhId, events);
}
-void SourceServiceDumpFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- std::vector args;
- std::u16string arg(reinterpret_cast(data), size / sizeof(char16_t));
- if (arg.empty() || std::all_of(arg.begin(), arg.end(), [](char16_t c) { return c == 0; })) {
- return;
- }
- args.push_back(arg);
-
- int fd = STDOUT_FILENO;
-
- sourceService_->Dump(fd, args);
-}
-
-void SourceServiceGetDumpInfoFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size == 0)) {
- return;
- }
-
- CameraDumpInfo camDump;
-
- sourceService_->GetDumpInfo(camDump);
-}
-
-void SourceServiceCamDevEraseFuzzTest(const uint8_t* data, size_t size)
-{
- if ((data == nullptr) || (size < sizeof(DCameraIndex))) {
- return;
- }
- int doubleNum = 2;
- DCameraIndex index;
- index.devId_ = ExtractString(data, 0, size / doubleNum);
- index.dhId_ = ExtractString(data, size / doubleNum, size / doubleNum);
-
- sourceService_->CamDevErase(index);
-}
-}
-}
+} // namespace DistributedHardware
+} // namespace OHOS
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
- /* Run your code on data */
OHOS::DistributedHardware::SourceServiceDCameraNotifyFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceOnStartFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceInitFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceOnStopFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceDumpFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceGetDumpInfoFuzzTest(data, size);
- OHOS::DistributedHardware::SourceServiceCamDevEraseFuzzTest(data, size);
return 0;
-}
-
+}
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..1ddc38d161d0268e08bab6d560c87945a052ca40
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/BUILD.gn
@@ -0,0 +1,86 @@
+# Copyright (c) 2023-2025 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("SourceServiceDumpFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/sourceservicedump"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer"
+
+ include_dirs =
+ [ "${innerkits_path}/native_cpp/camera_source/include/callback" ]
+
+ include_dirs += [
+ "include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${innerkits_path}/native_cpp/camera_source/include",
+ "${innerkits_path}/native_cpp/camera_source/include/callback",
+ "${services_path}/cameraservice/base/include",
+ "${services_path}/cameraservice/sourceservice/include/distributedcamera",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameradata",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerastate",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "sourceservicedump_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
+ "${services_path}/cameraservice/sourceservice:distributed_camera_source",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SourceServiceDumpFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "cJSON:cjson",
+ "c_utils:utils",
+ "distributed_hardware_fwk:distributed_av_receiver",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "distributed_hardware_fwk:libdhfwk_sdk",
+ "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1",
+ "eventhandler:libeventhandler",
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SourceServiceDumpFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2025 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/sourcefuzztest/sourceservicedump_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5a1287bdce3549cf7408ec13f72c004498aa4920
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 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 "sourceservicedump_fuzzer.h"
+#include "distributed_camera_source_service.h"
+#include "distributed_camera_constants.h"
+#include
+#include
+#include
+#include
+
+namespace OHOS {
+namespace DistributedHardware {
+
+void SourceServiceDumpFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size == 0)) {
+ return;
+ }
+
+ auto sourceService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, true);
+
+ std::vector args;
+ std::u16string arg(reinterpret_cast(data), size / sizeof(char16_t));
+ if (arg.empty() || std::all_of(arg.begin(), arg.end(), [](char16_t c) { return c == 0; })) {
+ return;
+ }
+ args.push_back(arg);
+ int fd = STDOUT_FILENO;
+
+ sourceService->Dump(fd, args);
+}
+
+} // namespace DistributedHardware
+} // namespace OHOS
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SourceServiceDumpFuzzTest(data, size);
+ return 0;
+}
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..8cb8fc13082a1972007093bc4aa5e0c74bf17f05
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicedump_fuzzer/sourceservicedump_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 SOURCESERVICEDUMP_FUZZER_H
+#define SOURCESERVICEDUMP_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sourceservicedump_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..f981696fd471003083b4be027888957daae6792f
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/BUILD.gn
@@ -0,0 +1,86 @@
+# Copyright (c) 2023-2025 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("SourceServiceGetDumpInfoFuzzTest") {
+ module_out_path = "${fuzz_test_output_path}/sourceservicegetdumpinfo"
+
+ fuzz_config_file = "${innerkits_path}/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer"
+
+ include_dirs =
+ [ "${innerkits_path}/native_cpp/camera_source/include/callback" ]
+
+ include_dirs += [
+ "include",
+ "${common_path}/include/constants",
+ "${common_path}/include/utils",
+ "${innerkits_path}/native_cpp/camera_source/include",
+ "${innerkits_path}/native_cpp/camera_source/include/callback",
+ "${services_path}/cameraservice/base/include",
+ "${services_path}/cameraservice/sourceservice/include/distributedcamera",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcameradata",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface",
+ "${services_path}/cameraservice/sourceservice/include/distributedcameramgr/dcamerastate",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "sourceservicegetdumpinfo_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_camera_utils",
+ "${innerkits_path}/native_cpp/camera_source:distributed_camera_source_sdk",
+ "${services_path}/cameraservice/sourceservice:distributed_camera_source",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SourceServiceGetDumpInfoFuzzTest\"",
+ "LOG_DOMAIN=0xD004150",
+ ]
+
+ external_deps = [
+ "cJSON:cjson",
+ "c_utils:utils",
+ "distributed_hardware_fwk:distributed_av_receiver",
+ "distributed_hardware_fwk:distributedhardwareutils",
+ "distributed_hardware_fwk:libdhfwk_sdk",
+ "drivers_interface_distributed_camera:libdistributed_camera_provider_proxy_1.1",
+ "eventhandler:libeventhandler",
+ "hilog:libhilog",
+ "ipc:ipc_core",
+ "safwk:system_ability_fwk",
+ "samgr:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SourceServiceGetDumpInfoFuzzTest" ]
+}
+###############################################################################
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..65af8ee8d11bf23407ea34d4de49f7cbb6a2b791
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/corpus/init
@@ -0,0 +1,14 @@
+# Copyright (c) 2025 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/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66e1dcac475475fb101b6f8670ec699e6e9696aa
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d09dfb3c3ba0522e3db1022ffd83c763c453b83
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 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 "sourceservicegetdumpinfo_fuzzer.h"
+#include "distributed_camera_source_service.h"
+#include "distributed_camera_constants.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+
+void SourceServiceGetDumpInfoFuzzTest(const uint8_t* data, size_t size)
+{
+ auto sourceService = std::make_shared(
+ DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, true);
+
+ CameraDumpInfo camDump;
+ sourceService->GetDumpInfo(camDump);
+}
+
+} // namespace DistributedHardware
+} // namespace OHOS
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ OHOS::DistributedHardware::SourceServiceGetDumpInfoFuzzTest(data, size);
+ return 0;
+}
+
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.h b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..2cf9cc2ae12d191be871753c2685a3d295611411
--- /dev/null
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicegetdumpinfo_fuzzer/sourceservicegetdumpinfo_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 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 SOURCESERVICEGETDUMPINFO_FUZZER_H
+#define SOURCESERVICEGETDUMPINFO_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sourceservicegetdumpinfo_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceserviceinitsource_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceserviceinitsource_fuzzer/BUILD.gn
index f7bfe008d0029dc5c248af788ff40ab3619b2fd3..95f4f2d5ba9e0783261789a43b5a75f52cc7478d 100644
--- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceserviceinitsource_fuzzer/BUILD.gn
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceserviceinitsource_fuzzer/BUILD.gn
@@ -47,6 +47,8 @@ ohos_fuzztest("SourceServiceInitSourceFuzzTest") {
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
]
sources = [ "sourceserviceinitsource_fuzzer.cpp" ]
diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicereleasesource_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicereleasesource_fuzzer/BUILD.gn
index 1783b4b52612b96ff6936d207c6f763d1fbfb321..9fdac93c0abe6166b6c7628d9003a73d61127ab7 100644
--- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicereleasesource_fuzzer/BUILD.gn
+++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceservicereleasesource_fuzzer/BUILD.gn
@@ -47,6 +47,8 @@ ohos_fuzztest("SourceServiceReleaseSourceFuzzTest") {
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
+ "-Dprivate=public",
+ "-Dprotected=public",
]
sources = [ "sourceservicereleasesource_fuzzer.cpp" ]
diff --git a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp
index 902ade161bde0bac7d5b24735c98e43fa7fcc160..6815249a416764b8ee02184415717478d24f27ea 100644
--- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp
+++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp
@@ -46,6 +46,7 @@ DistributedCameraSinkService::DistributedCameraSinkService(int32_t saId, bool ru
void DistributedCameraSinkService::OnStart()
{
+ // LCOV_EXCL_START
DHLOGI("DistributedCameraSinkService OnStart");
CHECK_AND_RETURN_LOG(state_ == DCameraServiceState::DCAMERA_SRV_STATE_RUNNING,
"sink service has already started.");
@@ -65,10 +66,12 @@ void DistributedCameraSinkService::OnStart()
}
}
DHLOGI("DCameraServiceState OnStart service success.");
+ // LCOV_EXCL_STOP
}
bool DistributedCameraSinkService::Init()
{
+ // LCOV_EXCL_START
DHLOGI("DistributedCameraSinkService start init");
DCameraSinkServiceIpc::GetInstance().Init();
if (!registerToService_) {
@@ -78,10 +81,12 @@ bool DistributedCameraSinkService::Init()
}
DHLOGI("DistributedCameraSinkService init success");
return true;
+ // LCOV_EXCL_STOP
}
void DistributedCameraSinkService::OnStop()
{
+ // LCOV_EXCL_START
DHLOGI("DistributedCameraSinkService OnStop service");
state_ = DCameraServiceState::DCAMERA_SRV_STATE_NOT_START;
registerToService_ = false;
@@ -96,6 +101,7 @@ void DistributedCameraSinkService::OnStop()
}
DCameraSinkServiceIpc::GetInstance().UnInit();
+ // LCOV_EXCL_STOP
}
int32_t DistributedCameraSinkService::InitSink(const std::string& params,
diff --git a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp
index 3cd928156d346887b798bb4d4c799ae4404d40bd..efeaa435a75eaad2e5f3abe83789d675c10a7e5a 100644
--- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp
+++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp
@@ -52,6 +52,7 @@ DistributedCameraSourceService::DistributedCameraSourceService(int32_t saId, boo
void DistributedCameraSourceService::OnStart()
{
+ // LCOV_EXCL_START
DHLOGI("start");
if (state_ == DCameraServiceState::DCAMERA_SRV_STATE_RUNNING) {
DHLOGI("DistributedCameraSourceService has already started.");
@@ -77,10 +78,12 @@ void DistributedCameraSourceService::OnStart()
state_ = DCameraServiceState::DCAMERA_SRV_STATE_RUNNING;
DHLOGI("start service success.");
+ // LCOV_EXCL_STOP
}
bool DistributedCameraSourceService::Init()
{
+ // LCOV_EXCL_START
DHLOGI("DistributedCameraSourceService start init");
DCameraSourceServiceIpc::GetInstance().Init();
if (!registerToService_) {
@@ -98,10 +101,12 @@ bool DistributedCameraSourceService::Init()
}
DHLOGI("DistributedCameraSourceService init success");
return true;
+ // LCOV_EXCL_STOP
}
void DistributedCameraSourceService::OnStop()
{
+ // LCOV_EXCL_START
DHLOGI("DistributedCameraSourceService OnStop service");
state_ = DCameraServiceState::DCAMERA_SRV_STATE_NOT_START;
registerToService_ = false;
@@ -124,6 +129,7 @@ void DistributedCameraSourceService::OnStop()
#ifdef DCAMERA_MMAP_RESERVE
ConverterHandle::GetInstance().DeInitConverter();
#endif
+ // LCOV_EXCL_STOP
}
int32_t DistributedCameraSourceService::InitSource(const std::string& params,
@@ -409,6 +415,7 @@ uint32_t DistributedCameraSourceService::GetCamDevNum()
void DistributedCameraSourceService::StartHicollieThread()
{
+ // LCOV_EXCL_START
auto taskFunc = [this]() {
std::lock_guard lock(camDevMutex_);
for (auto &iter : camerasMap_) {
@@ -434,6 +441,7 @@ void DistributedCameraSourceService::StartHicollieThread()
}
usleep(HICOLLIE_SLEEP_TIME_US);
}
+ // LCOV_EXCL_STOP
}
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/channel/src/dcamera_softbus_adapter.cpp b/services/channel/src/dcamera_softbus_adapter.cpp
index eaccfb3e8cf05f21d34a327a7d01358836f21c1b..0dbe8f5a013ea51374c8331099f51e3f3980f697 100644
--- a/services/channel/src/dcamera_softbus_adapter.cpp
+++ b/services/channel/src/dcamera_softbus_adapter.cpp
@@ -42,7 +42,7 @@ static QosTV g_qosInfo[] = {
static uint32_t g_QosTV_Param_Index = static_cast(sizeof(g_qosInfo) / sizeof(QosTV));
}
IMPLEMENT_SINGLE_INSTANCE(DCameraSoftbusAdapter);
-
+// LCOV_EXCL_START
static void DCameraSourceOnBind(int32_t socket, PeerSocketInfo info)
{
return;
@@ -104,7 +104,7 @@ static void DCameraSinkOnStream(int32_t socket, const StreamData *data, const St
DCameraSoftbusAdapter::GetInstance().SinkOnStream(socket, data, ext, param);
return;
}
-
+// LCOV_EXCL_STOP
DCameraSoftbusAdapter::DCameraSoftbusAdapter()
{
sessionModeAndDataTypeMap_[DCAMERA_SESSION_MODE_CTRL] = TransDataType::DATA_TYPE_BYTES;