diff --git a/bundle.json b/bundle.json index 3cedd469cb3ac537f37f6fe5393aa291f96a63bf..b3f9f233935caac12e1bbbcb5bd7492cf750bc1b 100644 --- a/bundle.json +++ b/bundle.json @@ -84,7 +84,6 @@ "//foundation/distributedhardware/distributedscreen/screenhandler/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/interfaces/innerkits/native_cpp/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/fuzztest:fuzztest", - "//foundation/distributedhardware/distributedscreen/services/screenservice/test/fuzztest:fuzztest", "//foundation/distributedhardware/distributedscreen/services/screentransport/test/fuzztest:fuzztest" ] } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp index 2852d9003f0c0ef46346d93c61459f0631d01136..1888eb30d9df2f4d7417b7b3c05fa98a4137a0c3 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensinkproxy_fuzzer/dscreen_sink_proxy_fuzzer.cpp @@ -40,7 +40,15 @@ void DscreenSinkProxyHandlerFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + if (remoteObject == nullptr) { + return; + } + std::shared_ptr dscreenSinkProxy = std::make_shared(remoteObject); dscreenSinkProxy->DScreenNotify(devId, eventCode, eventContent); diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp index 1a5b970f771efdf67d5e0194a95c67443be756fd..3239905330ae50a5f6902c826f52029db2dc25c5 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreensourceproxy_fuzzer/dscreen_source_proxy_fuzzer.cpp @@ -51,7 +51,15 @@ void DscreenSourceProxyHandlerFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + if (remoteObject == nullptr) { + return; + } + std::shared_ptr dscreenSourceProxy = std::make_shared(remoteObject); dscreenSourceProxy->InitSource(params, callback); diff --git a/services/screenservice/test/fuzztest/BUILD.gn b/services/screenservice/test/fuzztest/BUILD.gn deleted file mode 100644 index a63f7a6fdc52e1abee0baca3a5f5c163295c8027..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -group("fuzztest") { - testonly = true - - deps = [ "sinkservice_fuzzer:fuzztest" ] -} diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn deleted file mode 100644 index 581a9fc53d51075ba7ac783f883a1f5777815452..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/BUILD.gn +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import( - "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - -##############################fuzztest########################################## -ohos_fuzztest("SinkServiceFuzzTest") { - module_out_path = "distributed_screen/sinkservice" - - fuzz_config_file = - "${services_path}/screenservice/test/fuzztest/sinkservice_fuzzer" - - include_dirs = [ - "//third_party/json/include", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "//foundation/graphic/standard/interfaces/innerkits/surface", - "${windowmanager_path}/interfaces/innerkits/dm", - "${fwk_common_path}/utils/include", - ] - - include_dirs += [ - "./dscreenservice/include", - "./screenregionmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - "${common_path}/include", - "${services_path}/common/utils/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screenclient/include", - "${services_path}/screenservice/sinkservice/dscreenservice/include", - "${services_path}/screenservice/sinkservice/screenregionmgr/include", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "sink_service_fuzzer.cpp" ] - - deps = [ - "${common_path}:distributed_screen_utils", - "${services_path}/screenclient:distributed_screen_client", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${windowmanager_path}/dm:libdm", - "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", - "//foundation/graphic/standard/frameworks/surface:surface", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SinkServiceFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "multimedia_media_standard:media_client", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":SinkServiceFuzzTest" ] -} -############################################################################### diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init b/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init deleted file mode 100644 index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/corpus/init +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FUZZ \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml b/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp deleted file mode 100644 index f1988636684e5b3c696fec79760d19f968d64c07..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sink_service_fuzzer.h" - -#include -#include -#include - -#include "dscreen_sink_service.h" - -namespace OHOS { -namespace DistributedHardware { -void SinkServiceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size <= sizeof(int32_t))) { - return; - } - - int32_t saId = *(reinterpret_cast(data)); - bool runOnCreate = true; - std::shared_ptr sinkService = std::make_shared(saId, runOnCreate); - std::string params(reinterpret_cast(data), size); - std::string dhId(reinterpret_cast(data), size); - std::string param(reinterpret_cast(data), size); - std::string devId(reinterpret_cast(data), size); - int32_t eventCode = *(reinterpret_cast(data)); - std::string eventContent(reinterpret_cast(data), size); - - sinkService->DScreenNotify(devId, eventCode, eventContent); - sinkService->InitSink(params); - sinkService->SubscribeLocalHardware(dhId, param); - sinkService->UnsubscribeLocalHardware(dhId); - sinkService->ReleaseSink(); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::SinkServiceFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h b/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h deleted file mode 100644 index 3f40dfac695d56394a0f6fe263f92d1d004ff2fd..0000000000000000000000000000000000000000 --- a/services/screenservice/test/fuzztest/sinkservice_fuzzer/sink_service_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SINK_SERVICE_FUZZER_H -#define SINK_SERVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "sink_service_fuzzer" - -#endif \ No newline at end of file