diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn index 4d55ed50920207d89a6408c48432e79078143ba7..a4905fb7c5e9be1e444a63cc154995fdb5bbb999 100644 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ b/services/screenservice/test/fuzztest/BUILD.gn @@ -16,7 +16,7 @@ group("fuzztest") { deps = [ "sinkservice/dscreenservice/dscreensinkstub_fuzzer:fuzztest", - "sourceservice/dscreenmgr/onchange_fuzzer:fuzztest", + "sourceservice/dscreenmgr/dscreenmanager_fuzzer:fuzztest", "sourceservice/dscreenservice/dscreensourcecallbackproxy_fuzzer:fuzztest", "sourceservice/dscreenservice/dscreensourceservice_fuzzer:fuzztest", "sourceservice/dscreenservice/dscreensourcestub_fuzzer:fuzztest", diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/BUILD.gn similarity index 91% rename from services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn rename to services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/BUILD.gn index be9d7eaa253b5340bc29de0fd7335ccf79ce09a2..885e1a59bb134f6b26b8a8896f6c5f0bf5663021 100644 --- a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn +++ b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/BUILD.gn @@ -17,10 +17,10 @@ import("//build/test.gni") import("../../../../../../../distributedscreen.gni") ##############################fuzztest########################################## -ohos_fuzztest("OnChangeFuzzTest") { +ohos_fuzztest("DScreenManagerFuzzTest") { module_out_path = "${fuzz_test_path}/sourceservice" - fuzz_config_file = "${services_path}/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer" + fuzz_config_file = "${services_path}/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer" include_dirs = [ "./dscreenservice/include/callback", @@ -37,7 +37,7 @@ ohos_fuzztest("OnChangeFuzzTest") { configs = [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - sources = [ "onchange_fuzzer.cpp" ] + sources = [ "dscreenmanager_fuzzer.cpp" ] deps = [ "${services_path}/screenservice/sourceservice:distributed_screen_source", @@ -45,7 +45,7 @@ ohos_fuzztest("OnChangeFuzzTest") { defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"OnChangeFuzzTest\"", + "DH_LOG_TAG=\"DScreenManagerFuzzTest\"", "LOG_DOMAIN=0xD004140", ] @@ -64,6 +64,6 @@ ohos_fuzztest("OnChangeFuzzTest") { ############################################################################### group("fuzztest") { testonly = true - deps = [ ":OnChangeFuzzTest" ] + deps = [ ":DScreenManagerFuzzTest" ] } ############################################################################### diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/corpus/init b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/corpus/init similarity index 100% rename from services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/corpus/init rename to services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/corpus/init diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eab2ca7740c7a9bbe3d3863ceb8ea8b6782dadc6 --- /dev/null +++ b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2023-2024 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 "dscreenmanager_fuzzer.h" + +#include +#include + +#include "1.0/include/dscreen_manager.h" + +namespace OHOS { +namespace DistributedHardware { +namespace V1_0 { +void OnChangeFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint64_t))) { + return; + } + std::vector screenIds; + uint64_t screenIdOne = *(reinterpret_cast(data)); + screenIds.emplace_back(screenIdOne); + Rosen::ScreenGroupChangeEvent event = Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP; + DScreenGroupListener dScreenGroupListener; + dScreenGroupListener.OnChange(screenIds, event); +} + +void HandleScreenChangeFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint32_t))) { + return; + } + + uint32_t eventValue = *(reinterpret_cast(data)) % 3; + if ((eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP)) || + (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP)) || + (eventValue != static_cast(Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP))) { + return; + } + + std::shared_ptr dScreenCallback = std::make_shared(); + std::shared_ptr dScreen = std::make_shared("devId000", "dhId000", dScreenCallback); + Rosen::ScreenGroupChangeEvent event = static_cast(eventValue); + + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->HandleScreenChange(dScreen, event); +} + +void AddToGroupFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(uint64_t))) { + return; + } + + uint64_t screenId = *(reinterpret_cast(data)); + std::shared_ptr dScreenCallback = std::make_shared(); + std::shared_ptr dScreen = std::make_shared("devId000", "dhId000", dScreenCallback); + + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->AddToGroup(dScreen, screenId); + dscreenManager->RemoveFromGroup(dScreen, screenId); +} + +void DScreenCallbackOnRegResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string reqId(reinterpret_cast(data), size); + std::string screenId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + + std::shared_ptr dScreenCallback = std::make_shared(); + std::shared_ptr dScreen = std::make_shared("devId000", "dhId000", dScreenCallback); + dScreenCallback->OnRegResult(dScreen, screenId, status, dataStr); + dScreenCallback->OnUnregResult(dScreen, screenId, status, dataStr); +} + +void DScreenManagerOnUnregResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string reqId(reinterpret_cast(data), size); + int32_t status = *(reinterpret_cast(data)); + std::string dataStr(reinterpret_cast(data), size); + + std::shared_ptr dScreenCallback = std::make_shared(); + std::shared_ptr dScreen = std::make_shared("devId000", "dhId000", dScreenCallback); + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->OnRegResult(dScreen, reqId, status, dataStr); + dscreenManager->OnUnregResult(dScreen, reqId, status, dataStr); +} + +void EnableDistributedScreenFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + + std::string str(reinterpret_cast(data), size); + std::string devId(reinterpret_cast(data), size); + std::string dhId(reinterpret_cast(data), size); + std::string reqId(reinterpret_cast(data), size); + EnableParam param = {str, str, str, str}; + + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->EnableDistributedScreen(devId, dhId, param, reqId); + dscreenManager->DisableDistributedScreen(devId, dhId, reqId); +} + +void NotifyRemoteScreenServiceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::string devId(reinterpret_cast(data), size); + int32_t eventCode = *(reinterpret_cast(data)); + std::string eventContent(reinterpret_cast(data), size); + + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->NotifyRemoteScreenService(devId, eventCode, eventContent); +} + +void HandleNotifySetUpResultFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + + std::string remoteDevId(reinterpret_cast(data), size); + std::string eventContent(reinterpret_cast(data), size); + + std::shared_ptr dscreenManager = std::make_shared(); + dscreenManager->HandleNotifySetUpResult(remoteDevId, eventContent); +} + +} // namespace V1_0 +} // namespace DistributedHardware +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::V1_0::OnChangeFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::HandleScreenChangeFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::AddToGroupFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::DScreenCallbackOnRegResultFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::DScreenManagerOnUnregResultFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::EnableDistributedScreenFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::NotifyRemoteScreenServiceFuzzTest(data, size); + OHOS::DistributedHardware::V1_0::HandleNotifySetUpResultFuzzTest(data, size); + return 0; +} diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.h b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.h similarity index 93% rename from services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.h rename to services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.h index 26a3775e9a3c6f24fa58f6a5b4a6b82eb29c106e..91d433d33d08e29a9888b5b7241f8cd2f1a86cad 100644 --- a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.h +++ b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/dscreenmanager_fuzzer.h @@ -16,6 +16,6 @@ #ifndef ONCHANGE_FUZZER_H #define ONCHANGE_FUZZER_H -#define FUZZ_PROJECT_NAME "onchange_fuzzer" +#define FUZZ_PROJECT_NAME "dscreenmanager_fuzzer" #endif \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/project.xml b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/project.xml similarity index 100% rename from services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/project.xml rename to services/screenservice/test/fuzztest/sourceservice/dscreenmgr/dscreenmanager_fuzzer/project.xml diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.cpp b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.cpp deleted file mode 100644 index 44c0b0d86167a323a5348b619fdb926eaf8f17e8..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/onchange_fuzzer.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023-2024 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 "onchange_fuzzer.h" - -#include -#include - -#include "1.0/include/dscreen_manager.h" - -namespace OHOS { -namespace DistributedHardware { -namespace V1_0 { -void OnChangeFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(uint64_t))) { - return; - } - std::vector screenIds; - uint64_t screenIdOne = *(reinterpret_cast(data)); - screenIds.emplace_back(screenIdOne); - Rosen::ScreenGroupChangeEvent event = Rosen::ScreenGroupChangeEvent::ADD_TO_GROUP; - DScreenGroupListener dScreenGroupListener; - dScreenGroupListener.OnChange(screenIds, event); -} -} // namespace V1_0 -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::V1_0::OnChangeFuzzTest(data, size); - return 0; -} - diff --git a/services/softbusadapter/test/fuzztest/BUILD.gn b/services/softbusadapter/test/fuzztest/BUILD.gn index 5798ca82b03ba17d05090a81c76a70ebfd0e07c3..d04b76d9a4b022994ec3e4339836c8acec6faa4f 100644 --- a/services/softbusadapter/test/fuzztest/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/BUILD.gn @@ -14,12 +14,5 @@ group("fuzztest") { testonly = true - deps = [ - "softbusadapter_fuzzer:fuzztest", - "softbusonbytesreceived_fuzzer:fuzztest", - "softbusonmessagereceived_fuzzer:fuzztest", - "softbusonsessionclosed_fuzzer:fuzztest", - "softbusonsessionopened_fuzzer:fuzztest", - "softbusonstreamreceived_fuzzer:fuzztest", - ] + deps = [ "softbusadapter_fuzzer:fuzztest" ] } diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.cpp index 50223e1c7141f9a7df79be546a1d6ba11ee9d80c..53a500bcbcce3d76ae11d7d77c3e00a02eb10ecf 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.cpp @@ -19,9 +19,9 @@ #include "dscreen_errcode.h" #include "dscreen_util.h" #include "isoftbus_listener.h" +#include "softbus_adapter.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#include "softbus_adapter.h" namespace OHOS { namespace DistributedHardware { @@ -62,6 +62,138 @@ void SoftbusAdapterFuzzTest(const uint8_t* data, size_t size) adapter->SendSoftbusBytes(sessionId, adapterData, dataLen1); adapter->CloseSoftbusSession(sessionId); } + +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); +} + +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); +} + +void SoftbusOnSessionClosedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + int32_t sessionId = *(reinterpret_cast(data)); + std::shared_ptr adapter = std::make_shared(); + ShutdownReason reason = SHUTDOWN_REASON_UNKNOWN; + adapter->OnSoftbusSessionClosed(sessionId, reason); +} + +void SoftbusOnSessionOpenedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + int32_t sessionId = *(reinterpret_cast(data)); + PeerSocketInfo peerSocketInfo = { + .name = const_cast(PEER_SESSION_NAME.c_str()), + .networkId = const_cast(REMOTE_DEV_ID.c_str()), + .pkgName = const_cast(DSCREEN_PKG_NAME_TEST.c_str()), + .dataType = DATA_TYPE_BYTES + }; + std::shared_ptr adapter = std::make_shared(); + adapter->OnSoftbusSessionOpened(sessionId, peerSocketInfo); +} + +void SoftbusOnStreamReceivedFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(int32_t)))) { + return; + } + 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); +} + +void SoftbusRegisterSoftbusListenerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::shared_ptr listener = std::make_shared(); + std::string sessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + + std::shared_ptr softbusAdapter = std::make_shared(); + (void)softbusAdapter->RegisterSoftbusListener(listener, sessionName, peerDevId); + (void)softbusAdapter->UnRegisterSoftbusListener(sessionName, peerDevId); +} + +void SoftbusUnRegisterSoftbusListenerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string sessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + + std::shared_ptr softbusAdapter = std::make_shared(); + (void)softbusAdapter->UnRegisterSoftbusListener(sessionName, peerDevId); +} + +void SoftbusCreateSoftbusSessionServerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + std::string sessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + + std::shared_ptr softbusAdapter = std::make_shared(); + (void)softbusAdapter->CreateSoftbusSessionServer(pkgName, sessionName, peerDevId); + (void)softbusAdapter->RemoveSoftbusSessionServer(pkgName, sessionName, peerDevId); +} + +void SoftbusRemoveSoftbusSessionServerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + std::string sessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + + std::shared_ptr softbusAdapter = std::make_shared(); + (void)softbusAdapter->RemoveSoftbusSessionServer(pkgName, sessionName, peerDevId); +} + +void SoftbusOpenSoftbusSessionFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string mySessionName(reinterpret_cast(data), size); + std::string peerSessionName(reinterpret_cast(data), size); + std::string peerDevId(reinterpret_cast(data), size); + + std::shared_ptr softbusAdapter = std::make_shared(); + int32_t socketId = softbusAdapter->OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); + (void)softbusAdapter->CloseSoftbusSession(socketId); +} + } // namespace DistributedHardware } // namespace OHOS @@ -70,5 +202,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::DistributedHardware::SoftbusAdapterFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOnBytesReceivedFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOnMessageReceivedFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOnSessionClosedFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOnSessionOpenedFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOnStreamReceivedFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusRegisterSoftbusListenerFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusUnRegisterSoftbusListenerFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusCreateSoftbusSessionServerFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusRemoveSoftbusSessionServerFuzzTest(data, size); + OHOS::DistributedHardware::SoftbusOpenSoftbusSessionFuzzTest(data, size); return 0; } diff --git a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.h b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.h index d6ae1c1ca4ea879142db94f9ce7ef73a9ad2496d..4e1bde8c11ee43d46bd04ece77ec882a0070b982 100644 --- a/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.h +++ b/services/softbusadapter/test/fuzztest/softbusadapter_fuzzer/softbusadapter_fuzzer.h @@ -18,4 +18,20 @@ #define FUZZ_PROJECT_NAME "softbusadapter_fuzzer" +#include "isoftbus_listener.h" + +namespace OHOS { +namespace DistributedHardware { +class MockSoftbusListener : public ISoftbusListener { +public: + MockSoftbusListener() = default; + ~MockSoftbusListener() = default; + void OnSessionOpened(int32_t sessionId, PeerSocketInfo info) override {} + void OnSessionClosed(int32_t sessionId, ShutdownReason reason) override {} + void OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) override {} + void OnStreamReceived(int32_t sessionId, const StreamData *data, const StreamData *ext, + const StreamFrameInfo *param) override {} +}; +} // namespace DistributedHardware +} // namespace OHOS #endif diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn deleted file mode 100644 index 36b525b0f2adc730045a6f62d7da9345139f1e5f..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023-2024 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 = "${fuzz_test_path}/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer" - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "softbusonbytesreceived_fuzzer.cpp" ] - - include_dirs = [ - "${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", - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusOnBytesReceivedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] -} - -############################################################################### -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 deleted file mode 100644 index 2b595da0c26af63ffb2d5f4132c086b2e5986fce..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 5dde7dd20ce74e98371b7f3a9a0245eff26a4877..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 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" -#include "softbus_adapter.h" - -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); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::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 deleted file mode 100644 index 245aaab342df157b4e1deb9aaa2f1e26bfaf5d92..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 deleted file mode 100644 index f6dbb0ba84a34adb93253cc521e561f2868a5d4c..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023-2024 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 = "${fuzz_test_path}/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer" - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "softbusonmessagereceived_fuzzer.cpp" ] - - include_dirs = [ - "${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", - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusOnMessageReceivedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] -} - -############################################################################### -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 deleted file mode 100644 index 2b595da0c26af63ffb2d5f4132c086b2e5986fce..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 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 deleted file mode 100644 index ed35470116e59c8f5759820130cbe2666f882eaf..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023-2024 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" -#include "softbus_adapter.h" - -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); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::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 deleted file mode 100644 index 1fe5ddd594c86ce69f833954352d9a2297f0c8fb..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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/softbusonsessionclosed_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn deleted file mode 100644 index bb63ac686e428823e409caca3bd2e059de3a1036..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023-2024 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 = "${fuzz_test_path}/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer" - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "softbusonsessionclosed_fuzzer.cpp" ] - - include_dirs = [ - "${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", - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusOnSessionClosedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] -} - -############################################################################### -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 deleted file mode 100644 index 2b595da0c26af63ffb2d5f4132c086b2e5986fce..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 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 deleted file mode 100644 index ede42c686bfa8c8061598fc924eea5cb99efa595..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023-2024 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" -#include "softbus_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -void SoftbusOnSessionClosedFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - int32_t sessionId = *(reinterpret_cast(data)); - std::shared_ptr adapter = std::make_shared(); - ShutdownReason reason = SHUTDOWN_REASON_UNKNOWN; - adapter->OnSoftbusSessionClosed(sessionId, reason); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::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 deleted file mode 100644 index 8641aaaa2db177f4f941c12d679a9252c29ddea9..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 deleted file mode 100644 index 78ab9843e02cea48145988220ed1d30fd0ec2d76..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023-2024 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 = "${fuzz_test_path}/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer" - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "softbusonsessionopened_fuzzer.cpp" ] - - include_dirs = [ - "${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", - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusOnSessionOpenedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] -} - -############################################################################### -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 deleted file mode 100644 index 2b595da0c26af63ffb2d5f4132c086b2e5986fce..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 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 deleted file mode 100644 index a77c325180e427af84f2be7a74c78f284d04cb1b..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023-2024 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" -#include "softbus_adapter.h" - -namespace OHOS { -namespace DistributedHardware { - namespace { - const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa124"; - const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112124"; - const std::string DSCREEN_PKG_NAME_TEST = "ohos.dhardware.dscreen"; -} -void SoftbusOnSessionOpenedFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - int32_t sessionId = *(reinterpret_cast(data)); - PeerSocketInfo peerSocketInfo = { - .name = const_cast(PEER_SESSION_NAME.c_str()), - .networkId = const_cast(REMOTE_DEV_ID.c_str()), - .pkgName = const_cast(DSCREEN_PKG_NAME_TEST.c_str()), - .dataType = DATA_TYPE_BYTES - }; - std::shared_ptr adapter = std::make_shared(); - adapter->OnSoftbusSessionOpened(sessionId, peerSocketInfo); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::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 deleted file mode 100644 index 8dbb5a98a3755b96e7bca50afc896e9b225c701b..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7d6f71077fd266185a88a4a47ad5c398ac2eb858..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023-2024 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 = "${fuzz_test_path}/softbusadapter" - fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer" - - configs = - [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] - - sources = [ "softbusonstreamreceived_fuzzer.cpp" ] - - include_dirs = [ - "${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", - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", - "hilog:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SoftbusOnStreamReceivedFuzzTest\"", - "LOG_DOMAIN=0xD004140", - ] -} - -############################################################################### -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 deleted file mode 100644 index 2b595da0c26af63ffb2d5f4132c086b2e5986fce..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fdbc407f205680885fa42663163b5c987f123a6..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 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 deleted file mode 100644 index ea1869721265b4e1ad61d017fa3c63111ab469a1..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2023-2024 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" -#include "softbus_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -void SoftbusOnStreamReceivedFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - 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); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::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 deleted file mode 100644 index 245aaab342df157b4e1deb9aaa2f1e26bfaf5d92..0000000000000000000000000000000000000000 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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