diff --git a/bundle.json b/bundle.json
index 3250cc91439c7ad8c6a3337be41d285c0e132dc5..fcd77c3fe5ae09ceea0924a3ed05fdf253272992 100644
--- a/bundle.json
+++ b/bundle.json
@@ -81,8 +81,11 @@
"//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/unittest:SoftBusAdapterTest",
"//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test",
"//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest",
- "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest"
+ "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest",
+ "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest",
+ "//foundation/distributedhardware/distributedscreen/services/screenservice/test/fuzztest:fuzztest",
+ "//foundation/distributedhardware/distributedscreen/services/screentransport/test/fuzztest:fuzztest"
]
}
}
-}
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn
index 0d66577372d4db6ad43a13f56a0530ec52750746..7a1b57f8910727763eea32726d51a6c3907661d5 100644
--- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn
+++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer/BUILD.gn
@@ -19,7 +19,7 @@ import(
##############################fuzztest##########################################
ohos_fuzztest("DscreenSinkHandlerFuzzTest") {
- module_out_path = "distributed_screen/dscreensinkhandler_fuzzer"
+ module_out_path = "distributed_screen/dscreensinkhandler"
fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkhandler_fuzzer"
diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn
index 3c6054257925901df38f9ce907992afdbdd415f5..43962755096ed12ae967b491acfc6f63ae868fb0 100644
--- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn
+++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/BUILD.gn
@@ -19,7 +19,7 @@ import(
##############################fuzztest##########################################
ohos_fuzztest("DscreenSinkProxyFuzzTest") {
- module_out_path = "distributed_screen/dscreensinkproxy_fuzzer"
+ module_out_path = "distributed_screen/dscreensinkproxy"
fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer"
diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn
index 1251422236d1f5f879e1ac8574021e9d44a61d59..7567f729e087174dc394c8f8f8b0aaf55da3027a 100644
--- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn
+++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer/BUILD.gn
@@ -19,7 +19,7 @@ import(
##############################fuzztest##########################################
ohos_fuzztest("DscreenSourceHandlerFuzzTest") {
- module_out_path = "distributed_screen/dscreensourcehandler_fuzzer"
+ module_out_path = "distributed_screen/dscreensourcehandler"
fuzz_config_file = "${interfaces_path}/innerkits/native_cpp/test/fuzztest/dscreensourcehandler_fuzzer"
diff --git a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn
index a97ffedefd5a64718133e34c09cb452a4328e7d0..c003bc1910a376bbea75aeaf7bb0a85a46214d2b 100644
--- a/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn
+++ b/screenhandler/test/fuzztest/dscreenhandler_fuzzer/BUILD.gn
@@ -19,7 +19,7 @@ import(
##############################fuzztest##########################################
ohos_fuzztest("DscreenHandlerFuzzTest") {
- module_out_path = "distributed_screen/dscreenhandler_fuzzer"
+ module_out_path = "distributed_screen/dscreenhandler"
fuzz_config_file = "${distributedscreen_path}/screenhandler/test/fuzztest/dscreenhandler_fuzzer"
diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..a63f7a6fdc52e1abee0baca3a5f5c163295c8027
--- /dev/null
+++ b/services/screenservice/test/fuzztest/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+group("fuzztest") {
+ testonly = true
+
+ deps = [ "sinkservice_fuzzer:fuzztest" ]
+}
diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..581a9fc53d51075ba7ac783f883a1f5777815452
--- /dev/null
+++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn
@@ -0,0 +1,94 @@
+# 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/distributedscreen/distributedscreen.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("SinkServiceFuzzTest") {
+ module_out_path = "distributed_screen/sinkservice"
+
+ fuzz_config_file =
+ "${services_path}/screenservice/test/fuzztest/sinkservice_fuzzer"
+
+ include_dirs = [
+ "//third_party/json/include",
+ "//utils/native/base/include",
+ "//utils/system/safwk/native/include",
+ "//foundation/graphic/standard/interfaces/innerkits/surface",
+ "${windowmanager_path}/interfaces/innerkits/dm",
+ "${fwk_common_path}/utils/include",
+ ]
+
+ include_dirs += [
+ "./dscreenservice/include",
+ "./screenregionmgr/include",
+ "${interfaces_path}/innerkits/native_cpp/screen_sink/include",
+ "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback",
+ "${interfaces_path}/innerkits/native_cpp/screen_source/include",
+ "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback",
+ "${common_path}/include",
+ "${services_path}/common/utils/include",
+ "${services_path}/common/databuffer/include",
+ "${services_path}/common/screen_channel/include",
+ "${services_path}/screentransport/screensinktrans/include",
+ "${services_path}/screentransport/screensinkprocessor/include",
+ "${services_path}/screentransport/screensinkprocessor/decoder/include",
+ "${services_path}/screenclient/include",
+ "${services_path}/screenservice/sinkservice/dscreenservice/include",
+ "${services_path}/screenservice/sinkservice/screenregionmgr/include",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "sink_service_fuzzer.cpp" ]
+
+ deps = [
+ "${common_path}:distributed_screen_utils",
+ "${services_path}/screenclient:distributed_screen_client",
+ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans",
+ "${windowmanager_path}/dm:libdm",
+ "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink",
+ "//foundation/graphic/standard/frameworks/surface:surface",
+ "//utils/native/base:utils",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SinkServiceFuzzTest\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ external_deps = [
+ "hiviewdfx_hilog_native:libhilog",
+ "ipc:ipc_core",
+ "multimedia_media_standard:media_client",
+ "safwk:system_ability_fwk",
+ "samgr_standard:samgr_proxy",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SinkServiceFuzzTest" ]
+}
+###############################################################################
diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init b/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801
--- /dev/null
+++ b/services/screenservice/test/fuzztest/sinkservice_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/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml b/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec
--- /dev/null
+++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f1988636684e5b3c696fec79760d19f968d64c07
--- /dev/null
+++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sink_service_fuzzer.h"
+
+#include
+#include
+#include
+
+#include "dscreen_sink_service.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void SinkServiceFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size <= sizeof(int32_t))) {
+ return;
+ }
+
+ int32_t saId = *(reinterpret_cast(data));
+ bool runOnCreate = true;
+ std::shared_ptr sinkService = std::make_shared(saId, runOnCreate);
+ std::string params(reinterpret_cast(data), size);
+ std::string dhId(reinterpret_cast(data), size);
+ std::string param(reinterpret_cast(data), size);
+ std::string devId(reinterpret_cast(data), size);
+ int32_t eventCode = *(reinterpret_cast(data));
+ std::string eventContent(reinterpret_cast(data), size);
+
+ sinkService->DScreenNotify(devId, eventCode, eventContent);
+ sinkService->InitSink(params);
+ sinkService->SubscribeLocalHardware(dhId, param);
+ sinkService->UnsubscribeLocalHardware(dhId);
+ sinkService->ReleaseSink();
+}
+}
+}
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ /* Run your code on data */
+ OHOS::DistributedHardware::SinkServiceFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f40dfac695d56394a0f6fe263f92d1d004ff2fd
--- /dev/null
+++ b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_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 SINK_SERVICE_FUZZER_H
+#define SINK_SERVICE_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "sink_service_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..02b6da6be0e40c75ba479ec2d3c5d1a30fa57893
--- /dev/null
+++ b/services/screentransport/test/fuzztest/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+group("fuzztest") {
+ testonly = true
+
+ deps = [
+ "screendatachannel_fuzzer:fuzztest",
+ "screensourceprocessor_fuzzer:fuzztest",
+ "screensourcetrans_fuzzer:fuzztest",
+ ]
+}
diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..7895eec60a42e058d92f28478dd323b999734f70
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/BUILD.gn
@@ -0,0 +1,84 @@
+# 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/distributedscreen/distributedscreen.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("ScreenDataChannelFuzzTest") {
+ module_out_path = "distributed_screen/screendatachannel"
+
+ fuzz_config_file =
+ "${services_path}/screentransport/test/fuzztest/screendatachannel_fuzzer"
+
+ include_dirs = [
+ "//third_party/json/include",
+ "//foundation/graphic/standard/interfaces/innerkits/surface",
+ "${fwk_common_path}/utils/include",
+ ]
+
+ include_dirs += [
+ "./include",
+ "${services_path}/screentransport/test/unittest/screentranstestutils/include",
+ "${common_path}/include",
+ "${services_path}/common/databuffer/include",
+ "${services_path}/common/screen_channel/include",
+ "${services_path}/common/utils/include",
+ "${services_path}/screentransport/screensinkprocessor/include",
+ "${services_path}/screentransport/screensinktrans/include",
+ "${services_path}/screentransport/screensourcetrans/include",
+ "${services_path}/screentransport/screendatachannel/include",
+ "${services_path}/screentransport/screensourceprocessor/include",
+ "${services_path}/screentransport/screensourceprocessor/encoder/include",
+ "${services_path}/softbusadapter/include",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "screen_data_channel_fuzzer.cpp" ]
+
+ deps = [
+ "${fwk_utils_path}:distributedhardwareutils",
+ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans",
+ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans",
+ "//foundation/graphic/standard/frameworks/surface:surface",
+ "//utils/native/base:utils",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"ScreenDataChannelFuzzTest\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ external_deps = [
+ "dsoftbus_standard:softbus_client",
+ "hiviewdfx_hilog_native:libhilog",
+ "multimedia_media_standard:media_client",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":ScreenDataChannelFuzzTest" ]
+}
+###############################################################################
diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screendatachannel_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/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..27c26d11b7d89f7aef7835fb5f95f9e5ecaf6f9d
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..46058019dcde4b9f3450b91a4d6cfa0ac58e59c2
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_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 "screen_data_channel_fuzzer.h"
+
+#include
+#include
+
+#include "screen_data_channel_impl.h"
+#include "screen_sink_trans.h"
+#include "screen_source_trans.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void ScreenDataChannelFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(int32_t))) {
+ return;
+ }
+
+ std::string peerDevId(reinterpret_cast(data), size);
+ std::shared_ptr screenDataChannelImpl = std::make_shared(peerDevId);
+ std::shared_ptr listener = std::make_shared();
+ size_t capacity = size;
+ std::shared_ptr screenData = std::make_shared(capacity);
+
+ screenDataChannelImpl->CreateSession(listener);
+ screenDataChannelImpl->OpenSession();
+ screenDataChannelImpl->SendData(screenData);
+ screenDataChannelImpl->CloseSession();
+ screenDataChannelImpl->ReleaseSession();
+}
+}
+}
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ /* Run your code on data */
+ OHOS::DistributedHardware::ScreenDataChannelFuzzTest(data, size);
+
+ return 0;
+}
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..73d19ac775e2d7a3b3156144780217d8d8b0e720
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screendatachannel_fuzzer/screen_data_channel_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 SCREEN_DATA_CHANNEL_FUZZER_H
+#define SCREEN_DATA_CHANNEL_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "screen_data_channel_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..979a7ea02971c7180a7e08713524e807779cac34
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/BUILD.gn
@@ -0,0 +1,83 @@
+# 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/distributedscreen/distributedscreen.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("ScreenSourceProcessorFuzzTest") {
+ module_out_path = "distributed_screen/screensourceprocessor"
+
+ fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor_fuzzer"
+
+ include_dirs = [
+ "//third_party/json/include",
+ "//foundation/graphic/standard/interfaces/innerkits/surface",
+ "${fwk_common_path}/utils/include",
+ "${fwk_utils_path}/include/",
+ ]
+
+ include_dirs += [
+ "./include",
+ "${services_path}/screentransport/test/unittest/screentranstestutils/include",
+ "${common_path}/include",
+ "${services_path}/common/databuffer/include",
+ "${services_path}/common/screen_channel/include",
+ "${services_path}/common/utils/include",
+ "${services_path}/screentransport/test/unittest/screensourcetrans",
+ "${services_path}/screentransport/screensourcetrans/include",
+ "${services_path}/screentransport/screendatachannel/include",
+ "${services_path}/screentransport/screensourceprocessor/include",
+ "${services_path}/screentransport/screensourceprocessor/encoder/include",
+ "${services_path}/softbusadapter/include",
+ "${services_path}/screentransport/test/unittest/screensourceprocessor/include",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "screen_source_processor_fuzzer.cpp" ]
+
+ deps = [
+ "${fwk_utils_path}:distributedhardwareutils",
+ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans",
+ "//foundation/graphic/standard/frameworks/surface:surface",
+ "//utils/native/base:utils",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"ScreenSourceProcessorFuzzTest\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ external_deps = [
+ "dsoftbus_standard:softbus_client",
+ "hiviewdfx_hilog_native:libhilog",
+ "multimedia_media_standard:media_client",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":ScreenSourceProcessorFuzzTest" ]
+}
+###############################################################################
diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourceprocessor_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/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..688a95e16f70e518f5357d7f8d474adac18e1d98
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "screen_source_processor_fuzzer.h"
+
+#include
+#include
+
+#include "image_source_processor.h"
+#include "screen_source_trans.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void ScreenSourceProcessorFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(uint32_t))) {
+ return;
+ }
+
+ std::shared_ptr imageSourceProcessor = std::make_shared();
+ std::shared_ptr param = std::make_shared();
+ uint32_t screenWidth = *(reinterpret_cast(data));
+ uint32_t screenHeight = *(reinterpret_cast(data));
+ uint32_t videoWidth = *(reinterpret_cast(data));
+ uint32_t videoHeight = *(reinterpret_cast(data));
+ param->SetScreenWidth(screenWidth);
+ param->SetScreenHeight(screenHeight);
+ param->SetVideoWidth(videoWidth);
+ param->SetScreenHeight(videoHeight);
+ std::shared_ptr listener = std::make_shared();
+
+ imageSourceProcessor->ConfigureImageProcessor(*param, *param, listener);
+ imageSourceProcessor->GetImageSurface();
+ imageSourceProcessor->StartImageProcessor();
+ imageSourceProcessor->StopImageProcessor();
+ imageSourceProcessor->ReleaseImageProcessor();
+}
+}
+}
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ /* Run your code on data */
+ OHOS::DistributedHardware::ScreenSourceProcessorFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..36cfae0822e77e9c485314b8f56d4246c9f14ba3
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourceprocessor_fuzzer/screen_source_processor_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 SCREEN_SOURCE_PROCESSOR_FUZZER_H
+#define SCREEN_SOURCE_PROCESSOR_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "screen_source_processor_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..bee0caa718a73b859439830d3f14600b93dff4b3
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/BUILD.gn
@@ -0,0 +1,95 @@
+# 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/distributedscreen/distributedscreen.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("ScreenSourceTransFuzzTest") {
+ module_out_path = "distributed_screen/screensourcetrans"
+
+ fuzz_config_file =
+ "${services_path}/screentransport/test/fuzztest/screensourcetrans_fuzzer"
+
+ include_dirs = [
+ "//third_party/json/include",
+ "//foundation/graphic/standard/interfaces/innerkits/surface",
+ "${windowmanager_path}/interfaces/innerkits/dm",
+ "${fwk_common_path}/log/include",
+ "${fwk_common_path}/utils/include",
+ "${fwk_utils_path}/include/",
+ "${fwk_utils_path}/include/log",
+ ]
+
+ include_dirs += [
+ "./include",
+ "${services_path}/screentransport/test/unittest/screentranstestutils/include",
+ "${common_path}/include",
+ "${services_path}/common/databuffer/include",
+ "${services_path}/common/screen_channel/include",
+ "${services_path}/common/utils/include",
+ "${services_path}/screentransport/screensinktrans/include",
+ "${services_path}/screentransport/screensinkprocessor/include",
+ "${services_path}/screentransport/test/unittest/screensourcetrans/include",
+ "${services_path}/screentransport/screensourcetrans/include",
+ "${services_path}/screentransport/screendatachannel/include",
+ "${services_path}/screentransport/screensourceprocessor/include",
+ "${services_path}/screentransport/screensourceprocessor/encoder/include",
+ "${services_path}/softbusadapter/include",
+ "${services_path}/screenservice/sourceservice/dscreenmgr/include",
+ "//foundation/graphic/standard/rosen/modules/render_service_base/include",
+ "${interfaces_path}/innerkits/native_cpp/screen_sink/include",
+ "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "screen_source_trans_fuzzer.cpp" ]
+
+ deps = [
+ "${fwk_utils_path}:distributedhardwareutils",
+ "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk",
+ "${services_path}/screenservice/sourceservice:distributed_screen_source",
+ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans",
+ "${windowmanager_path}/dm:libdm",
+ "//foundation/graphic/standard/frameworks/surface:surface",
+ "//utils/native/base:utils",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"ScreenSourceTransFuzzTest\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ external_deps = [
+ "dsoftbus_standard:softbus_client",
+ "hiviewdfx_hilog_native:libhilog",
+ "multimedia_media_standard:media_client",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":ScreenSourceTransFuzzTest" ]
+}
+###############################################################################
diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourcetrans_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/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..50c6bea8148e45d71eb1642fde382aab25b8a87a
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "screen_source_trans_fuzzer.h"
+
+#include
+#include
+
+#include "dscreen.h"
+#include "dscreen_errcode.h"
+#include "dscreen_manager.h"
+#include "screen_source_trans.h"
+#include "video_param.h"
+#include "screentrans_test_utils.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void ScreenSourceTransFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(uint32_t))) {
+ return;
+ }
+
+ std::shared_ptr screenSourceTrans = std::make_shared();
+ std::shared_ptr param = std::make_shared();
+ uint32_t screenWidth = *(reinterpret_cast(data));
+ uint32_t screenHeight = *(reinterpret_cast(data));
+ uint32_t videoWidth = *(reinterpret_cast(data));
+ uint32_t videoHeight = *(reinterpret_cast(data));
+ param->SetScreenWidth(screenWidth);
+ param->SetScreenHeight(screenHeight);
+ param->SetVideoWidth(videoWidth);
+ param->SetScreenHeight(videoHeight);
+ std::string peerDevId(reinterpret_cast(data), size);
+ std::string devId(reinterpret_cast(data), size);
+ std::string dhId(reinterpret_cast(data), size);
+ std::shared_ptr dScreenCallback = std::make_shared();
+ std::shared_ptr callBack = std::make_shared(devId, dhId, dScreenCallback);
+
+ screenSourceTrans->SetUp(*param, *param, peerDevId);
+ screenSourceTrans->GetImageSurface();
+ screenSourceTrans->Start();
+ screenSourceTrans->RegisterStateCallback(callBack);
+ screenSourceTrans->Stop();
+ screenSourceTrans->Release();
+}
+}
+}
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ /* Run your code on data */
+ OHOS::DistributedHardware::ScreenSourceTransFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5e54307bb91e6f24d4d1b9cb06abca1bca7c560
--- /dev/null
+++ b/services/screentransport/test/fuzztest/screensourcetrans_fuzzer/screen_source_trans_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 SCREEN_SOURCE_TRANS_FUZZER_H
+#define SCREEN_SOURCE_TRANS_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "screen_source_trans_fuzzer"
+
+#endif
\ No newline at end of file
diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..598cc3f332cc6315badc1a7f4416575c6838584d
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+group("fuzztest") {
+ testonly = true
+
+ deps = [ "softbusadapter_fuzzer:fuzztest" ]
+}
diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..016636e86ebcc10db30e2023a558220c216544ba
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/BUILD.gn
@@ -0,0 +1,82 @@
+# 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/distributedscreen/distributedscreen.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("SoftbusAdapterFuzzTest") {
+ module_out_path = "distributed_screen/softbusadapter"
+
+ fuzz_config_file =
+ "${services_path}/softbusadapter/test/fuzztest/softbusadapter_fuzzer"
+
+ include_dirs = [
+ "//third_party/json/include",
+ "//foundation/graphic/standard/interfaces/innerkits/surface",
+ "${fwk_common_path}/utils/include",
+ "${fwk_utils_path}/include/",
+ ]
+
+ include_dirs += [
+ "./include",
+ "${common_path}/include",
+ "${services_path}/common/databuffer/include",
+ "${services_path}/common/screen_channel/include",
+ "${services_path}/common/utils/include",
+ "${services_path}/screentransport/test/unittest/screensourcetrans/include",
+ "${services_path}/screentransport/screensourcetrans/include",
+ "${services_path}/screentransport/screendatachannel/include",
+ "${services_path}/screentransport/screensourceprocessor/include",
+ "${services_path}/screentransport/screensourceprocessor/encoder/include",
+ "${services_path}/softbusadapter/include",
+ ]
+
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [ "softbus_adapter_fuzzer.cpp" ]
+
+ deps = [
+ "${fwk_utils_path}:distributedhardwareutils",
+ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans",
+ "//foundation/graphic/standard/frameworks/surface:surface",
+ "//utils/native/base:utils",
+ ]
+
+ defines = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"SoftbusAdapterFuzzTest\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ external_deps = [
+ "dsoftbus_standard:softbus_client",
+ "hiviewdfx_hilog_native:libhilog",
+ "multimedia_media_standard:media_client",
+ ]
+}
+
+###############################################################################
+group("fuzztest") {
+ testonly = true
+ deps = [ ":SoftbusAdapterFuzzTest" ]
+}
+###############################################################################
diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..bc977bd9738ee9a70b362067f57a9c63d3adb801
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/softbusadapter_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/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a6345f5495d3e4b83f41f654d1b59df9c82d7d8
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "softbus_adapter_fuzzer.h"
+
+#include
+#include
+#include
+
+#include "isoftbus_listener.h"
+#include "screen_data_channel_impl.h"
+#include "softbus_adapter.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+void SoftbusAdapterFuzzTest(const uint8_t* data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(int32_t))) {
+ return;
+ }
+
+ std::string pkgname(reinterpret_cast(data), size);
+ std::string sessionName(reinterpret_cast(data), size);
+ std::string peerDevId(reinterpret_cast(data), size);
+ std::string mySessionName(reinterpret_cast(data), size);
+ std::string peerSessionName(reinterpret_cast(data), size);
+ int32_t sessionId = *(reinterpret_cast(data));
+ void *datapointer = const_cast(data);
+ int32_t dataLen = static_cast(size);
+ StreamData streamdata = {reinterpret_cast(const_cast(data)), static_cast(size)};
+ StreamData ext = {0};
+ StreamFrameInfo frameInfo = {0};
+ std::shared_ptr listener = std::make_shared(peerDevId);
+ int32_t result = *(reinterpret_cast(data));
+ unsigned int datalength = static_cast(size);
+ int eventId = *(reinterpret_cast(data));
+ int tvCount = *(reinterpret_cast(data));
+ QosTv tvList;
+
+ SoftbusAdapter::GetInstance().CreateSoftbusSessionServer(pkgname, sessionName, peerDevId);
+ SoftbusAdapter::GetInstance().RemoveSoftbusSessionServer(pkgname, sessionName, peerDevId);
+ SoftbusAdapter::GetInstance().OpenSoftbusSession(mySessionName, peerSessionName, peerDevId);
+ SoftbusAdapter::GetInstance().CloseSoftbusSession(sessionId);
+ SoftbusAdapter::GetInstance().SendSoftbusBytes(sessionId, datapointer, dataLen);
+ SoftbusAdapter::GetInstance().SendSoftbusStream(sessionId, &streamdata, &ext, &frameInfo);
+ SoftbusAdapter::GetInstance().RegisterSoftbusListener(listener, sessionName, peerDevId);
+ SoftbusAdapter::GetInstance().UnRegisterSoftbusListener(sessionName, peerDevId);
+ SoftbusAdapter::GetInstance().OnSoftbusSessionOpened(sessionId, result);
+ SoftbusAdapter::GetInstance().OnSoftbusSessionClosed(sessionId);
+ SoftbusAdapter::GetInstance().OnBytesReceived(sessionId, datapointer, dataLen);
+ SoftbusAdapter::GetInstance().OnStreamReceived(sessionId, &streamdata, &ext, &frameInfo);
+ SoftbusAdapter::GetInstance().OnMessageReceived(sessionId, datapointer, datalength);
+ SoftbusAdapter::GetInstance().OnQosEvent(sessionId, eventId, tvCount, &tvList);
+}
+}
+}
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ /* Run your code on data */
+ OHOS::DistributedHardware::SoftbusAdapterFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f8959fec9a504634fb35d6a4b59c03d10de023b4
--- /dev/null
+++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbus_adapter_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 TEST_SOFTBUS_ADAPTER_FUZZER_H
+#define TEST_SOFTBUS_ADAPTER_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "test_softbus_adapter_fuzzer"
+
+#endif
\ No newline at end of file