diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn index 12a3d2a88f23e0a98a0711ff680d7b070891f6ee..1d01597317b073207805692e1c2b0ddabedca5a0 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn @@ -42,6 +42,11 @@ group("fuzztest") { "sinkservicestopcapture_fuzzer:fuzztest", "sinkservicesubscribelocalhardware_fuzzer:fuzztest", "sinkserviceunsubscribelocalhardware_fuzzer:fuzztest", + "softbusonsourcebytesreceived_fuzzer:fuzztest", + "softbusonsourcemessagereceived_fuzzer:fuzztest", + "softbusonsourcesessionclosed_fuzzer:fuzztest", + "softbusonsourcesessionopened_fuzzer:fuzztest", + "softbusonsourcestreamreceived_fuzzer:fuzztest", "sourcehandlerconfigdistributedhardware_fuzzer:fuzztest", "sourcehandlerinitsource_fuzzer:fuzztest", "sourcehandlerregisterdistributedhardware_fuzzer:fuzztest", diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3787f72aa02d9392d05aa480f2c12ca4c3e595cf --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSourceBytesReceivedFuzzTest") { + module_out_path = "distributed_camera/softbusonsourcebytesreceived" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer" + + include_dirs = [ + "${fwk_common_path}/utils/include", + "${services_path}/cameraservice/base/include", + ] + + include_dirs += [ + "${services_path}/channel/include", + "${common_path}/include/constants", + "${common_path}/include/utils", + "//foundation//communication//dsoftbus//core//common//include", + "${fwk_innerkits_path}/include", + "//third_party/json/include", + "${feeding_smoother_path}/base", + "${feeding_smoother_path}/derived", + "${feeding_smoother_path}/utils", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "softbusonsourcebytesreceived_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/channel:distributed_camera_channel", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSourceBytesReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSourceBytesReceivedFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_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/fuzztest/softbusonsourcebytesreceived_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31ae400173d08fcc3a6ec8dffee5c50a72666a74 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * 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 "softbusonsourcebytesreceived_fuzzer.h" + +#include "dcamera_softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSourceBytesReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + int32_t sessionId = *(reinterpret_cast(data)); + const void *receivedData = reinterpret_cast(data); + uint32_t dataLen = *(reinterpret_cast(data)); + + DCameraSoftbusAdapter::GetInstance().OnSourceBytesReceived(sessionId, receivedData, dataLen); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSourceBytesReceivedFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2fca48ce524faa82f7b54c48f321bf9b66ba15d8 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcebytesreceived_fuzzer/softbusonsourcebytesreceived_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 SOFTBUSONSOURCEBYTESRECEIVED_FUZZER_H +#define SOFTBUSONSOURCEBYTESRECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsourcebytesreceived_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a16e2faf1e79b3708ee867d82a81c60ea419ab94 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSourceMessageReceivedFuzzTest") { + module_out_path = "distributed_camera/softbusonsourcemessagereceived" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer" + + include_dirs = [ + "${fwk_common_path}/utils/include", + "${services_path}/cameraservice/base/include", + ] + + include_dirs += [ + "${services_path}/channel/include", + "${common_path}/include/constants", + "${common_path}/include/utils", + "//foundation//communication//dsoftbus//core//common//include", + "${fwk_innerkits_path}/include", + "//third_party/json/include", + "${feeding_smoother_path}/base", + "${feeding_smoother_path}/derived", + "${feeding_smoother_path}/utils", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "softbusonsourcemessagereceived_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/channel:distributed_camera_channel", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSourceMessageReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSourceMessageReceivedFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_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/fuzztest/softbusonsourcemessagereceived_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2264e61b63e04177ed0160cf3e05d030d73a8af5 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * 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 "softbusonsourcemessagereceived_fuzzer.h" + +#include "dcamera_softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSourceMessageReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + int32_t sessionId = *(reinterpret_cast(data)); + const void *receivedData = reinterpret_cast(data); + uint32_t dataLen = *(reinterpret_cast(data)); + + DCameraSoftbusAdapter::GetInstance().OnSourceMessageReceived(sessionId, receivedData, dataLen); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSourceMessageReceivedFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..57fe94ba765439589ffe4812c32f20f4c863bc5f --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcemessagereceived_fuzzer/softbusonsourcemessagereceived_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 SOFTBUSONSOURCEMESSAGERECEIVED_FUZZER_H +#define SOFTBUSONSOURCEMESSAGERECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsourcemessagereceived_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d66dc9a215562088de53e1359540993c11be0ce1 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSourceSessionClosedFuzzTest") { + module_out_path = "distributed_camera/softbusonsourcesessionclosed" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer" + + include_dirs = [ + "${fwk_common_path}/utils/include", + "${services_path}/cameraservice/base/include", + ] + + include_dirs += [ + "${services_path}/channel/include", + "${common_path}/include/constants", + "${common_path}/include/utils", + "//foundation//communication//dsoftbus//core//common//include", + "${fwk_innerkits_path}/include", + "//third_party/json/include", + "${feeding_smoother_path}/base", + "${feeding_smoother_path}/derived", + "${feeding_smoother_path}/utils", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "softbusonsourcesessionclosed_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/channel:distributed_camera_channel", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSourceSessionClosedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSourceSessionClosedFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_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/fuzztest/softbusonsourcesessionclosed_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..30d30b963e3fce4fe0cd482c2e836b9c1a307ded --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_fuzzer.cpp @@ -0,0 +1,42 @@ +/* + * 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 "softbusonsourcesessionclosed_fuzzer.h" + +#include "dcamera_softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSourceSessionClosedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + int32_t sessionId = *(reinterpret_cast(data)); + + DCameraSoftbusAdapter::GetInstance().OnSourceSessionClosed(sessionId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSourceSessionClosedFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..28477dd55b057731c410282c83e12663ab19ae73 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionclosed_fuzzer/softbusonsourcesessionclosed_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 SOFTBUSONSOURCESESSIONCLOSED_FUZZER_H +#define SOFTBUSONSOURCESESSIONCLOSED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsourcesessionclosed_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d700b12d86f252594be14bdbd4e49c900e5c8f10 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSourceSessionOpenedFuzzTest") { + module_out_path = "distributed_camera/softbusonsourcesessionopened" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer" + + include_dirs = [ + "${fwk_common_path}/utils/include", + "${services_path}/cameraservice/base/include", + ] + + include_dirs += [ + "${services_path}/channel/include", + "${common_path}/include/constants", + "${common_path}/include/utils", + "//foundation//communication//dsoftbus//core//common//include", + "${fwk_innerkits_path}/include", + "//third_party/json/include", + "${feeding_smoother_path}/base", + "${feeding_smoother_path}/derived", + "${feeding_smoother_path}/utils", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "softbusonsourcesessionopened_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/channel:distributed_camera_channel", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSourceSessionOpenedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSourceSessionOpenedFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_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/fuzztest/softbusonsourcesessionopened_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3e96b2b8a1656851b66a5d0f05e64d00d7eed3f --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_fuzzer.cpp @@ -0,0 +1,43 @@ +/* + * 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 "softbusonsourcesessionopened_fuzzer.h" + +#include "dcamera_softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSourceSessionOpenedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + int32_t sessionId = *(reinterpret_cast(data)); + int32_t result = *(reinterpret_cast(data)); + + DCameraSoftbusAdapter::GetInstance().OnSourceSessionOpened(sessionId, result); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSourceSessionOpenedFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5c6badcaf6cb7acda7c0553e06d63471ff171cdd --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcesessionopened_fuzzer/softbusonsourcesessionopened_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 SOFTBUSONSOURCESESSIONOPENED_FUZZER_H +#define SOFTBUSONSOURCESESSIONOPENED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsourcesessionopened_fuzzer" + +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9358f96993ec915e939cc75a175599d49e3120a0 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/BUILD.gn @@ -0,0 +1,76 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSourceStreamReceivedFuzzTest") { + module_out_path = "distributed_camera/softbusonsourcestreamreceived" + + fuzz_config_file = "${innerkits_path}/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer" + + include_dirs = [ + "${fwk_common_path}/utils/include", + "${services_path}/cameraservice/base/include", + ] + + include_dirs += [ + "${services_path}/channel/include", + "${common_path}/include/constants", + "${common_path}/include/utils", + "//foundation//communication//dsoftbus//core//common//include", + "${fwk_innerkits_path}/include", + "//third_party/json/include", + "${feeding_smoother_path}/base", + "${feeding_smoother_path}/derived", + "${feeding_smoother_path}/utils", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "softbusonsourcestreamreceived_fuzzer.cpp" ] + + deps = [ + "${common_path}:distributed_camera_utils", + "${services_path}/channel:distributed_camera_channel", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSourceStreamReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSourceStreamReceivedFuzzTest" ] +} +############################################################################### diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/corpus/init b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_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/fuzztest/softbusonsourcestreamreceived_fuzzer/project.xml b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03419b7b460979993c9da820584c954bfdcba566 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_fuzzer.cpp @@ -0,0 +1,45 @@ +/* + * 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 "softbusonsourcestreamreceived_fuzzer.h" + +#include "dcamera_softbus_adapter.h" + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSourceStreamReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + int32_t sessionId = *(reinterpret_cast(data)); + const StreamData *receivedData = reinterpret_cast(data); + const StreamData *ext = reinterpret_cast(data); + const StreamFrameInfo *param = reinterpret_cast(data); + + DCameraSoftbusAdapter::GetInstance().OnSourceStreamReceived(sessionId, receivedData, ext, param); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSourceStreamReceivedFuzzTest(data, size); + return 0; +} + diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_fuzzer.h b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ff9f3c409bde7e7d537e5d71e9f1fd62ecdfa532 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/softbusonsourcestreamreceived_fuzzer/softbusonsourcestreamreceived_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 SOFTBUSONSOURCESTREAMRECEIVED_FUZZER_H +#define SOFTBUSONSOURCESTREAMRECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsourcestreamreceived_fuzzer" + +#endif \ No newline at end of file