diff --git a/bundle.json b/bundle.json index ef4881fe496ce582a8b40d9b7645fb0eb96342d4..4598e365de738bd10d4cc06c84a34cfabbaa1b1e 100644 --- a/bundle.json +++ b/bundle.json @@ -92,12 +92,14 @@ "//foundation/distributedhardware/distributed_screen/services/screenservice/test/unittest/sinkservice/screenregionmgr:DscreenRegionMgrTest", "//foundation/distributedhardware/distributed_screen/services/screenservice/test/unittest/sourceservice/dscreenservice:DScreenSourceStubTest", "//foundation/distributedhardware/distributed_screen/services/screenservice/test/unittest/sourceservice/dscreenmgr:DscreenMgrTest", + "//foundation/distributedhardware/distributed_screen/services/screentransport/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_screen/services/screentransport/test/unittest:screen_transport_test", "//foundation/distributedhardware/distributed_screen/services/softbusadapter/test/unittest:SoftBusAdapterTest", "//foundation/distributedhardware/distributed_screen/services/common/test/unittest:service_common_test", "//foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/test/unittest:screen_interface_test", "//foundation/distributedhardware/distributed_screen/services/screenclient/test/unittest:ScreenClientTest", "//foundation/distributedhardware/distributed_screen/screenhandler/test/fuzztest:fuzztest", + "//foundation/distributedhardware/distributed_screen/services/softbusadapter/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributed_screen/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer:OnChangeFuzzTest" ] diff --git a/services/screentransport/test/fuzztest/BUILD.gn b/services/screentransport/test/fuzztest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0bf5bdfc987ba65de160e917693602b919e08698 --- /dev/null +++ b/services/screentransport/test/fuzztest/BUILD.gn @@ -0,0 +1,25 @@ +# 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. + +group("fuzztest") { + testonly = true + + deps = [ + "screensinkprocessor/onbufferavailable_fuzzer:fuzztest", + "screensourceprocessor/onbufferavailable_fuzzer:fuzztest", + "screensourceprocessor/onerror_fuzzer:fuzztest", + "screensourceprocessor/oninputbufferavailable_fuzzer:fuzztest", + "screensourceprocessor/onoutputbufferavailable_fuzzer:fuzztest", + "screensourceprocessor/onoutputformatchanged_fuzzer:fuzztest", + ] +} diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5ff3e0aada0472b4defd6fbff213d088bf222400 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn @@ -0,0 +1,78 @@ +# 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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnBufferAvailableFuzzTest") { + module_out_path = "distributed_screen/imagesinkdecoder" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer" + + include_dirs = [ + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/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 = [ "onbufferavailable_fuzzer.cpp" ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"HandlerOnRemoteSinkSvrDiedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnBufferAvailableFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_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/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b8a45c0477fa9ed986477534e3308522d55a9948 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * 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 "onbufferavailable_fuzzer.h" + +#include +#include + +#include "avcodec_common.h" +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "format.h" +#include "iimage_source_processor_listener.h" +#include "screen_sink_trans.h" +#include "image_sink_decoder.h" +#include "image_source_encoder.h" +#include "image_encoder_callback.h" +#include "iscreen_channel_listener.h" + +namespace OHOS { +namespace DistributedHardware { +void OnBufferAvailableFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr decoder = std::make_shared(listener); + std::shared_ptr bufferListen = std::make_shared(decoder); + bufferListen->OnBufferAvailable(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnBufferAvailableFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..325f4c1a8fdc3a2eb4d9201ca035b1915aa3775d --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/onbufferavailable_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 ONBUFFERAVAILABLE_FUZZER_H +#define ONBUFFERAVAILABLE_FUZZER_H + +#define FUZZ_PROJECT_NAME "OnBufferAvailable_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3efc0547e4361c617657b21900c0b08cbb401ad9 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn @@ -0,0 +1,78 @@ +# 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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnBufferAvailableFuzzTest") { + module_out_path = "distributed_screen/imagesourceencoder" + + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer" + + include_dirs = [ + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/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 = [ "onbufferavailable_fuzzer.cpp" ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"HandlerOnRemoteSinkSvrDiedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnBufferAvailableFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_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/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eb93a4a7dcc9b26a9c1ffad0b7a932ab5182958c --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_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 "onbufferavailable_fuzzer.h" + +#include +#include + +#include "image_source_encoder.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void OnBufferAvailableFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr encoder = std::make_shared(listener); + std::shared_ptr bufferListen = std::make_shared(encoder); + bufferListen->OnBufferAvailable(); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnBufferAvailableFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7a4f288e9eb790a3d6453e9b120d336cff756e48 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/onbufferavailable_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 ONREMOTESINKSVRDIED_FUZZER_H +#define ONREMOTESINKSVRDIED_FUZZER_H + +#define FUZZ_PROJECT_NAME "onbufferavailable_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..888d278480ec0c6c21a7aa93b4d669491b6754c0 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnErrorFuzzTest") { + module_out_path = "distributed_screen/imageencodercallback" + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "onerror_fuzzer.cpp" ] + + include_dirs = [ + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"OnErrorFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnErrorFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0fce198e61ab974d27add61e020a82d15461d59 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * 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 "onerror_fuzzer.h" + +#include + +#include "avcodec_common.h" +#include "dscreen_constants.h" +#include "format.h" +#include "iimage_source_processor_listener.h" +#include "image_source_encoder.h" +#include "image_encoder_callback.h" +#include "iscreen_channel_listener.h" +#include "media_errors.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void OnErrorFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr encoder = std::make_shared(listener); + std::shared_ptr encoderCallback = std::make_shared(encoder); + int32_t errorCode = *(reinterpret_cast(data)); + Media::AVCodecErrorType errorType = Media::AVCODEC_ERROR_INTERNAL; + encoderCallback->OnError(errorType, errorCode); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnErrorFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0be593c89b806524dd7fbd63c93ac567136ec302 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/onerror_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 ONERROR_FUZZER_H +#define ONERROR_FUZZER_H + +#define FUZZ_PROJECT_NAME "onerror_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0bd72993a758ed1d2e8378a56b1cd4add871ab22 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnInputBufferAvailableFuzzTest") { + module_out_path = "distributed_screen/imageencodercallback" + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "oninputbufferavailable_fuzzer.cpp" ] + + include_dirs = [ + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"OnInputBufferAvailableFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnInputBufferAvailableFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3bd7c3dd107df482aa501a7ca91d26b586acbf58 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_fuzzer.cpp @@ -0,0 +1,48 @@ +/* + * 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 "oninputbufferavailable_fuzzer.h" + +#include + +#include "avcodec_common.h" +#include "format.h" +#include "image_encoder_callback.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void OnInputBufferAvailableFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(uint32_t)))) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr encoder = std::make_shared(listener); + std::shared_ptr encoderCallback = std::make_shared(encoder); + uint32_t index = *(reinterpret_cast(data)); + encoderCallback->OnInputBufferAvailable(index); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnInputBufferAvailableFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9fc11e6ef8de6294a32676c04c6af6d11e449fe5 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/oninputbufferavailable_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 ONINPUTBUFFERAVAILABLE_FUZZER_H +#define ONINPUTBUFFERAVAILABLE_FUZZER_H + +#define FUZZ_PROJECT_NAME "oninputbufferavailable_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..951e1cef5a601f54f88b8a52700ac258dd86e400 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn @@ -0,0 +1,77 @@ +# 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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnOutputBufferAvailableFuzzTest") { + module_out_path = "distributed_screen/imageencodercallback" + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "onoutputbufferavailable_fuzzer.cpp" ] + + include_dirs = [ + "${services_path}/screentransport/test/unittest/screentranstestutils/include", + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"OnOutputBufferAvailableFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnOutputBufferAvailableFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd0d7bd98a99c171f0d275cdbaef1fc263a49fbc --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_fuzzer.cpp @@ -0,0 +1,50 @@ +/* + * 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 "onoutputbufferavailable_fuzzer.h" + +#include + +#include "avcodec_common.h" +#include "format.h" +#include "image_encoder_callback.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void OnOutputBufferAvailableFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(uint32_t)))) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr encoder = std::make_shared(listener); + std::shared_ptr encoderCallback = std::make_shared(encoder); + uint32_t index = *(reinterpret_cast(data)); + Media::AVCodecBufferInfo info = *(reinterpret_cast(data)); + Media::AVCodecBufferFlag flag = Media::AVCODEC_BUFFER_FLAG_NONE; + encoderCallback->OnOutputBufferAvailable(index, info, flag); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnOutputBufferAvailableFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e3ae9b34040e3925ceda4cf64f8ef206d20b989b --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/onoutputbufferavailable_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 ONOUTPUTBUFFERAVAILABLE_FUZZER_H +#define ONOUTPUTBUFFERAVAILABLE_FUZZER_H + +#define FUZZ_PROJECT_NAME "onoutputbufferavailable_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a36b4c44f7f585438f582c3a35065b1af82c0e24 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_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("../../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("OnOutputFormatChangedFuzzTest") { + module_out_path = "distributed_screen/imageencodercallback" + fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "onoutputformatchanged_fuzzer.cpp" ] + + include_dirs = [ + "${common_path}/include", + "${fwk_common_path}/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screendatachannel/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensourcetrans/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/softbusadapter/include", + ] + + deps = [ + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "c_utils:utils", + "distributed_hardware_fwk:libdhfwk_sdk", + "graphic_standard:surface", + "graphic_standard:sync_fence", + "ipc:ipc_core", + "player_framework:media_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"OnOutputFormatChangedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":OnOutputFormatChangedFuzzTest" ] +} +############################################################################### diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/corpus/init b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e74b8d33b83e11f27441ce7fa74f22ef3ea78e67 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * 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 "onoutputformatchanged_fuzzer.h" + +#include + +#include "avcodec_common.h" +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "format.h" +#include "iimage_source_processor_listener.h" +#include "image_source_encoder.h" +#include "image_encoder_callback.h" +#include "iscreen_channel_listener.h" +#include "media_errors.h" +#include "screen_source_trans.h" + +namespace OHOS { +namespace DistributedHardware { +void OnOutputFormatChangedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::shared_ptr encoder = std::make_shared(listener); + std::shared_ptr encoderCallback = std::make_shared(encoder); + + Media::Format format; + encoderCallback->OnOutputFormatChanged(format); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::OnOutputFormatChangedFuzzTest(data, size); + return 0; +} + diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.h b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..13d2edaf7b1672a7bba7e80dd5ef03e0ffe8db87 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/onoutputformatchanged_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 ONOUTPUTFORMATCHANGED_FUZZER_H +#define ONOUTPUTFORMATCHANGED_FUZZER_H + +#define FUZZ_PROJECT_NAME "onoutputformatchanged_fuzzer" + +#endif \ No newline at end of file diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/project.xml b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6ad49ae6d5d4199e0e1136721a7b85c10ae5f05f --- /dev/null +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -0,0 +1,25 @@ +# 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. + +group("fuzztest") { + testonly = true + + deps = [ + "softbusonbytesreceived_fuzzer:fuzztest", + "softbusonmessagereceived_fuzzer:fuzztest", + "softbusonqosevent_fuzzer:fuzztest", + "softbusonsessionclosed_fuzzer:fuzztest", + "softbusonsessionopened_fuzzer:fuzztest", + "softbusonstreamreceived_fuzzer:fuzztest", + ] +} diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..da20ac0d89cff42bda2e67bb1eb4ad92100f5bb7 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn @@ -0,0 +1,64 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnBytesReceivedFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonbytesreceived_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnBytesReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnBytesReceivedFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..42d3239e6f7430d34db03bc9aee98a0ef0ea1ffe --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * 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 "softbusonbytesreceived_fuzzer.h" + +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnBytesReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + int32_t sessionId = *(reinterpret_cast(data)); + void *adapterData = nullptr; + uint32_t dataLen = *(reinterpret_cast(data)); + std::shared_ptr adapter = std::make_shared(); + adapter->OnBytesReceived(sessionId, adapterData, dataLen); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnBytesReceivedFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..245aaab342df157b4e1deb9aaa2f1e26bfaf5d92 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_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 SOFTBUSONBYTESRECEIVED_FUZZER_H +#define SOFTBUSONBYTESRECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonbytesreceived_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a45d99e45757fd0b02a6d5993bd94a71ac82dc2d --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn @@ -0,0 +1,64 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnMessageReceivedFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonmessagereceived_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnMessageReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnMessageReceivedFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0278d3c129b0c6613fa70f7521f4b2da2912847 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * 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 "softbusonmessagereceived_fuzzer.h" + +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnMessageReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + int32_t sessionId = *(reinterpret_cast(data)); + void *adapterData = nullptr; + unsigned int dataLen = *(reinterpret_cast(data)); + std::shared_ptr adapter = std::make_shared(); + adapter->OnMessageReceived(sessionId, adapterData, dataLen); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnMessageReceivedFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..1fe5ddd594c86ce69f833954352d9a2297f0c8fb --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_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 SOFTBUSONMESSAGESECEIVED_FUZZER_H +#define SOFTBUSONMESSAGESECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonmessagereceived_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..89eabc1ac40d2687ee86abb9c946737a09c616b4 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/BUILD.gn @@ -0,0 +1,65 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnQosEventFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = + "${services_path}/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonqosevent_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnQosEventFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnQosEventFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3034e2cff1bcb8d62abf66dfbfb72a0d37c779e3 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * 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 "softbusonqosevent_fuzzer.h" + +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnQosEventFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int)))) { + return; + } + int sessionId = *(reinterpret_cast(data)); + int eventId = *(reinterpret_cast(data)); + int tvCount = *(reinterpret_cast(data)); + const QosTv *tvList = nullptr; + std::shared_ptr adapter = std::make_shared(); + adapter->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::SoftbusOnQosEventFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..eb1f0c0bce9fd6233fd1142e6e10d01ae7d6e825 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonqosevent_fuzzer/softbusonqosevent_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 SOFTBUSONQOSEVENT_FUZZER_H +#define SOFTBUSONQOSEVENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonqosevent_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3e155b99c7663bcea239d3bed6328415d8eb886e --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn @@ -0,0 +1,64 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSessionClosedFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonsessionclosed_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSessionClosedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSessionClosedFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a051a61f43b878f3afe4d81ef918a366dc05542 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * 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 "softbusonsessionclosed_fuzzer.h" + +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSessionClosedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + std::string peerDevId(reinterpret_cast(data), size); + int32_t sessionId = *(reinterpret_cast(data)); + std::shared_ptr adapter = std::make_shared(); + adapter->OnSoftbusSessionClosed(sessionId); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSessionClosedFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8641aaaa2db177f4f941c12d679a9252c29ddea9 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_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 SOFTBUSONSESSIONCLOSED_FUZZER_H +#define SOFTBUSONSESSIONCLOSED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsessionclosed_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9fe272c76a040dc1a5e355efcad851aed2e528b1 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn @@ -0,0 +1,64 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnSessionOpenedFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonsessionopened_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnSessionOpenedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnSessionOpenedFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7240ebf2b907acd1a487bd0e24e340bdff7ac983 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp @@ -0,0 +1,52 @@ +/* + * 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 "softbusonsessionopened_fuzzer.h" + +#include + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnSessionOpenedFuzzTest(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)); + std::shared_ptr adapter = std::make_shared(); + adapter->OnSoftbusSessionOpened(sessionId, result); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnSessionOpenedFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8dbb5a98a3755b96e7bca50afc896e9b225c701b --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_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 SOFTBUSONSESSIONOPENED_FUZZER_H +#define SOFTBUSONSESSIONOPENED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonsessionopened_fuzzer" + +#endif \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9dab5d47cc40d15c9aec3fea11b95762f52da0b1 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn @@ -0,0 +1,64 @@ +# 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("../../../../../distributedscreen.gni") + +##############################fuzztest########################################## +ohos_fuzztest("SoftbusOnStreamReceivedFuzzTest") { + module_out_path = "distributed_screen/softbusadapter" + fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer" + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "softbusonstreamreceived_fuzzer.cpp" ] + + include_dirs = [ + "${av_transport_path}/common/include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/common/utils/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", + ] + + deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans" ] + + external_deps = [ + "c_utils:utils", + "dsoftbus:softbus_client", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SoftbusOnStreamReceivedFuzzTest\"", + "LOG_DOMAIN=0xD004100", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":SoftbusOnStreamReceivedFuzzTest" ] +} +############################################################################### diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/corpus/init b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..2b595da0c26af63ffb2d5f4132c086b2e5986fce --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/corpus/init @@ -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. + */ + +FUZZ \ No newline at end of file diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/project.xml b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..468d16fb8d90830d2b069b2b835a277038d28546 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp @@ -0,0 +1,53 @@ +/* + * 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 "softbusonstreamreceived_fuzzer.h" + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_util.h" +#include "isoftbus_listener.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" +#define private public +#include "softbus_adapter.h" +#undef private + +namespace OHOS { +namespace DistributedHardware { +void SoftbusOnStreamReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + std::string peerDevId(reinterpret_cast(data), size); + int32_t sessionId = *(reinterpret_cast(data)); + StreamData *stream = nullptr; + StreamData *ext = nullptr; + StreamFrameInfo *info = nullptr; + std::shared_ptr adapter = std::make_shared(); + adapter->OnStreamReceived(sessionId, stream, ext, info); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::SoftbusOnStreamReceivedFuzzTest(data, size); + return 0; +} + diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..245aaab342df157b4e1deb9aaa2f1e26bfaf5d92 --- /dev/null +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_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 SOFTBUSONBYTESRECEIVED_FUZZER_H +#define SOFTBUSONBYTESRECEIVED_FUZZER_H + +#define FUZZ_PROJECT_NAME "softbusonbytesreceived_fuzzer" + +#endif \ No newline at end of file