From 530040c393581368f81c9f1c631481b111aa656a Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 30 Aug 2023 14:55:47 +0800 Subject: [PATCH] fix fuzz bug Signed-off-by: gaoqiang_strong --- .../subscribelocalhardware_fuzzer.cpp | 7 ++++--- .../unsubscribelocalhardware_fuzzer.cpp | 5 +++-- .../sinkproxydscreennotify_fuzzer.cpp | 7 ++++--- .../proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp | 5 +++-- 4 files changed, 14 insertions(+), 10 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 87d9c445..17eff228 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -25,6 +25,7 @@ namespace OHOS { namespace DistributedHardware { +constexpr int32_t DISTRIBUTED_HARDWARE_DM_SA_ID = 4802; void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -39,8 +40,8 @@ void SubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - int32_t saId = *(reinterpret_cast(data)); - sptr remoteObject = samgr->GetSystemAbility(saId); + + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp index 7c39d54c..7631c026 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/unsubscribelocalhardware_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -25,6 +25,7 @@ namespace OHOS { namespace DistributedHardware { +constexpr int32_t DISTRIBUTED_HARDWARE_DM_SA_ID = 4802; void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -39,7 +40,7 @@ void UnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } 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 0d97564c..557544d5 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -25,6 +25,7 @@ namespace OHOS { namespace DistributedHardware { +constexpr int32_t DISTRIBUTED_HARDWARE_DM_SA_ID = 4802; void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -40,8 +41,8 @@ void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) if (samgr == nullptr) { return; } - int32_t saId = *(reinterpret_cast(data)); - sptr remoteObject = samgr->GetSystemAbility(saId); + + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp index 32acc082..85ac6c86 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/dscreennotify_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -25,6 +25,7 @@ namespace OHOS { namespace DistributedHardware { +constexpr int32_t DISTRIBUTED_HARDWARE_DM_SA_ID = 4802; void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -41,7 +42,7 @@ void DScreenNotifyFuzzTest(const uint8_t* data, size_t size) return; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); + sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_DM_SA_ID); if (remoteObject == nullptr) { return; } -- Gitee