From a020420f2d8d8e014ade682cc3e7c83e3c52e762 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 18 Aug 2023 11:36:28 +0800 Subject: [PATCH 1/2] fix fuzz bug Signed-off-by: gaoqiang_strong --- .../subscribelocalhardware_fuzzer.cpp | 4 ++-- .../configdistributedhardware_fuzzer.cpp | 4 ++-- .../registerdistributedhardware_fuzzer.cpp | 4 ++-- .../unregisterdistributedhardware_fuzzer.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp index 8dac4383..87d9c445 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/subscribelocalhardware_fuzzer.cpp @@ -39,8 +39,8 @@ void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = samgr->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp index a097bafb..f71fa609 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/configdistributedhardware_fuzzer.cpp @@ -41,8 +41,8 @@ void ConfigDistributedHardwareFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = samgr->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp index 82e40466..ab96db45 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/registerdistributedhardware_fuzzer.cpp @@ -46,8 +46,8 @@ void RegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = samgr->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp index 73357b41..bc050c5f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/unregisterdistributedhardware_fuzzer.cpp @@ -41,8 +41,8 @@ void UnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = samgr->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } -- Gitee From ab01183987e155abd281d0f690d832d79e1673ac Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 18 Aug 2023 16:10:14 +0800 Subject: [PATCH 2/2] fix bug Signed-off-by: gaoqiang_strong --- .../sinkproxydscreennotify_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp index f33a9c7c..0d97564c 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/sinkproxydscreennotify_fuzzer.cpp @@ -40,8 +40,8 @@ void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + int32_t saId = *(reinterpret_cast(data)); + sptr remoteObject = samgr->GetSystemAbility(saId); if (remoteObject == nullptr) { return; } -- Gitee