From 2a8789bea30dab8b3d77d3c677071b8d3a8676a2 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Tue, 27 May 2025 19:43:31 +0800 Subject: [PATCH 1/8] fuzz Signed-off-by: l30054665 --- .../softbus_listener_fuzzer/BUILD.gn | 92 +++++++++++++++++++ .../softbus_listener_fuzzer/corpus/init | 13 +++ .../softbus_listener_fuzzer/project.xml | 25 +++++ .../shift_lnn_gear_device_service_fuzzer.cpp | 44 +++++++++ .../shift_lnn_gear_device_service_fuzzer.h | 21 +++++ 5 files changed, 195 insertions(+) create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/corpus/init create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/project.xml create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn b/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn new file mode 100644 index 000000000..a43f96e63 --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn @@ -0,0 +1,92 @@ +# 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("//foundation/distributedhardware/device_manager/device_manager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = "${devicemanager_path}/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer" + + include_dirs = [ + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc/standard", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/notify", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/ipc/standard", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo/", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", + ] + + cflags = [ + "-g", + "-O0", + "-Dprivate=public", + "-Dprotected=public", + "-Werror", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "shift_lnn_gear_device_service_fuzzer.cpp" ] + + deps = [ + "${devicemanager_path}/services/service:devicemanagerservicetest", + "${utils_path}:devicemanagerutilstest", + ] + + external_deps = [ + "ability_base:want", + "cJSON:cjson", + "device_auth:deviceauth_sdk", + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + "dsoftbus:softbus_client", + "ffrt:libffrt", + "hilog:libhilog", + "init:libbegetutil", + "ipc:ipc_single", + "safwk:system_ability_fwk", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"ShiftLNNGearDeviceServiceFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":ShiftLNNGearDeviceServiceFuzzTest" ] +} +############################################################################### diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/corpus/init b/test/servicesfuzztest/softbus_listener_fuzzer/corpus/init new file mode 100644 index 000000000..d9719cafa --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# 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/test/servicesfuzztest/softbus_listener_fuzzer/project.xml b/test/servicesfuzztest/softbus_listener_fuzzer/project.xml new file mode 100644 index 000000000..bac4974e9 --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp new file mode 100644 index 000000000..dbaad02fd --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * 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 +#include +#include "device_manager_service.h" +#include "shift_lnn_gear_device_service_fuzzer.h" + +namespace OHOS { +namespace DistributedHardware { +void ShiftLNNGearDeviceServiceFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + std::string pkgName(reinterpret_cast(data), size); + std::string callerId(reinterpret_cast(data), size); + bool isRefresh = true; + + DeviceManagerService::GetInstance().ShiftLNNGear(pkgName, callerId, isRefresh, false); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::ShiftLNNGearDeviceServiceFuzzTest(data, size); + + return 0; +} \ No newline at end of file diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h new file mode 100644 index 000000000..22aa9d595 --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_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 SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H +#define SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H + +#define FUZZ_PROJECT_NAME "shiftlnngeardeviceservice_fuzzer" + +#endif // SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H \ No newline at end of file -- Gitee From 5f06387caeac9232a9eee24250d30a819f513cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Tue, 27 May 2025 13:34:58 +0000 Subject: [PATCH 2/8] update test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../softbus_listener_fuzzer/BUILD.gn | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn b/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn index a43f96e63..8ededc494 100644 --- a/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2022-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 @@ -17,11 +17,13 @@ import("//build/test.gni") import("//foundation/distributedhardware/device_manager/device_manager.gni") ##############################fuzztest########################################## -ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { +ohos_fuzztest("DmSoftbusListenerFuzzTest") { module_out_path = fuzz_test_output_path - fuzz_config_file = "${devicemanager_path}/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer" + fuzz_config_file = + "${devicemanager_path}/test/servicesfuzztest/dmsoftbuslistener_fuzzer" include_dirs = [ + "${utils_path}/include", "${innerkits_path}/native_cpp/include", "${innerkits_path}/native_cpp/include/ipc/standard", "${innerkits_path}/native_cpp/include/ipc", @@ -29,7 +31,6 @@ ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", - "${utils_path}/include", "${utils_path}/include/ipc/standard", "${servicesimpl_path}/include", "${servicesimpl_path}/include/dependency/timer", @@ -39,8 +40,8 @@ ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { "${servicesimpl_path}/include/adapter", "${servicesimpl_path}/include/ipc/standard", "${servicesimpl_path}/include/dependency/hichain", - "${servicesimpl_path}/include/deviceinfo/", "${servicesimpl_path}/include/devicestate", + "${devicemanager_path}/test/unittest/mock", "${servicesimpl_path}/include/ability", "${servicesimpl_path}/include/config", ] @@ -55,13 +56,20 @@ ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { "-fno-omit-frame-pointer", ] - sources = [ "shift_lnn_gear_device_service_fuzzer.cpp" ] + sources = [ "dm_softbus_listener_fuzzer.cpp" ] deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest", + "${json_path}:devicemanagerjson", "${utils_path}:devicemanagerutilstest", ] + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"DmSoftbusListenerFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] + external_deps = [ "ability_base:want", "cJSON:cjson", @@ -75,18 +83,12 @@ ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { "ipc:ipc_single", "safwk:system_ability_fwk", ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"ShiftLNNGearDeviceServiceFuzzTest\"", - "LOG_DOMAIN=0xD004110", - ] } ############################################################################### group("fuzztest") { testonly = true - deps = [ ":ShiftLNNGearDeviceServiceFuzzTest" ] + deps = [ ":DmSoftbusListenerFuzzTest" ] } ############################################################################### -- Gitee From 292b09c2c64825b5841620f17c92de1c0df26eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Tue, 27 May 2025 13:37:02 +0000 Subject: [PATCH 3/8] 1 a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../dm_softbus_listener_fuzzer.cpp | 106 ++++++++++++++++++ .../shift_lnn_gear_device_service_fuzzer.cpp | 44 -------- 2 files changed, 106 insertions(+), 44 deletions(-) create mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp delete mode 100644 test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp b/test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp new file mode 100644 index 000000000..69153252c --- /dev/null +++ b/test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 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 +#include +#include +#include + +#include "dm_constants.h" +#include "dm_device_info.h" +#include "device_manager_service.h" +#include "device_manager_impl.h" +#include "device_manager.h" +#include "device_manager_callback.h" +#include "dm_softbus_listener_fuzzer.h" +#include "softbus_listener.h" + +namespace OHOS { +namespace DistributedHardware { +void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < (sizeof(uint16_t) + (sizeof(int32_t) + sizeof(int32_t))) || + (size > DM_MAX_DEVICE_ID_LEN))) { + return; + } + + FuzzedDataProvider fdp(data, size); + DmDeviceInfo deviceInfo; + deviceInfo.deviceTypeId = fdp.ConsumeIntegral(); + deviceInfo.range = fdp.ConsumeIntegral(); + deviceInfo.networkType = fdp.ConsumeIntegral(); + deviceInfo.extraData = fdp.ConsumeRandomLengthString(); + SoftbusListener::DeviceNameChange(deviceInfo); + SoftbusListener::DeviceScreenStatusChange(deviceInfo); + + int32_t errcode = fdp.ConsumeIntegral(); + uint16_t deviceTypeId = fdp.ConsumeIntegral(); + string proofInfoStr = fdp.ConsumeRandomLengthString(); + SoftbusListener::CredentialAuthStatusProcess(proofInfoStr, deviceTypeId, errcode); + + const char* proofInfo = proofInfoStr.c_str(); + DevUserInfo localDevUserInfo; + localDevUserInfo.deviceId = fdp.ConsumeRandomLengthString(); + localDevUserInfo.userId = fdp.ConsumeIntegral(); + DevUserInfo remoteDevUserInfo; + remoteDevUserInfo.deviceId = fdp.ConsumeRandomLengthString(); + remoteDevUserInfo.userId = fdp.ConsumeIntegral(); + string remoteAclList = fdp.ConsumeRandomLengthString(); + SoftbusListener::OnSyncLocalAclList(localDevUserInfo, remoteDevUserInfo, remoteAclList); + + string aclList = fdp.ConsumeRandomLengthString(); + SoftbusListener::OnGetAclListHash(localDevUserInfo, remoteDevUserInfo, aclList); + + uint32_t proofLen = fdp.ConsumeIntegral(); + SoftbusListener::OnCredentialAuthStatus(proofInfo, proofLen, deviceTypeId, errcode); + + uint16_t typeValue = fdp.ConsumeIntegral(); + NodeStatusType type = static_cast(typeValue); + NodeStatus status; + status.basicInfo.deviceTypeId = fdp.ConsumeIntegral(); + status.basicInfo.osType = fdp.ConsumeIntegral(); + status.reserved[0] = fdp.ConsumeIntegral(); + SoftbusListener::OnDeviceScreenStatusChanged(type, &status); + + SoftbusListener listener; + std::string networkIdStr = fdp.ConsumeRandomLengthString(); + const char* networkId = networkIdStr.c_str(); + int32_t networkType = fdp.ConsumeIntegral(); + listener.GetNetworkTypeByNetworkId(networkId, networkType); + + std::string name = fdp.ConsumeRandomLengthString(); + SoftbusListener::CloseDmRadarHelperObj(name); + + std::string msg = fdp.ConsumeRandomLengthString(); + listener.SendAclChangedBroadcast(msg); + + int32_t screenStatus = fdp.ConsumeIntegral(); + listener.GetDeviceScreenStatus(networkId, screenStatus); + + listener.DeleteCacheDeviceInfo(); + + std::string displayName = fdp.ConsumeRandomLengthString(); + listener.SetLocalDisplayName(displayName); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::DmSoftbusListenerFuzzTest(data, size); + return 0; +} diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp deleted file mode 100644 index dbaad02fd..000000000 --- a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.cpp +++ /dev/null @@ -1,44 +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. - */ - -#include -#include -#include "device_manager_service.h" -#include "shift_lnn_gear_device_service_fuzzer.h" - -namespace OHOS { -namespace DistributedHardware { -void ShiftLNNGearDeviceServiceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size == 0)) { - return; - } - std::string pkgName(reinterpret_cast(data), size); - std::string callerId(reinterpret_cast(data), size); - bool isRefresh = true; - - DeviceManagerService::GetInstance().ShiftLNNGear(pkgName, callerId, isRefresh, false); -} -} -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::ShiftLNNGearDeviceServiceFuzzTest(data, size); - - return 0; -} \ No newline at end of file -- Gitee From 7b9a9856d76d5ebf9f863c68e0805dbac9db9975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Tue, 27 May 2025 13:37:32 +0000 Subject: [PATCH 4/8] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../shift_lnn_gear_device_service_fuzzer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h index 22aa9d595..cfa39a672 100644 --- a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h +++ b/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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 @@ -13,9 +13,9 @@ * limitations under the License. */ -#ifndef SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H -#define SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H +#ifndef DM_SOFTBUS_LISTENER_FUZZER_H +#define DM_SOFTBUS_LISTENER_FUZZER_H -#define FUZZ_PROJECT_NAME "shiftlnngeardeviceservice_fuzzer" +#define FUZZ_PROJECT_NAME "dm_softbus_listener_fuzzer" -#endif // SHIFT_LNN_GEAR_DEVICE_SERVICE_FUZZER_H \ No newline at end of file +#endif // DM_SOFTBUS_LISTENER_FUZZER_H -- Gitee From 270815bbb1fa4d19d9be70ba1eb4f7a595d87b22 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Tue, 27 May 2025 21:39:26 +0800 Subject: [PATCH 5/8] fuzz Signed-off-by: l30054665 --- .../BUILD.gn | 0 .../corpus/init | 0 .../dm_softbus_listener_fuzzer.cpp | 0 .../dm_softbus_listener_fuzzer.h} | 0 .../project.xml | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename test/servicesfuzztest/{softbus_listener_fuzzer => dmsoftbuslistener_fuzzer}/BUILD.gn (100%) rename test/servicesfuzztest/{softbus_listener_fuzzer => dmsoftbuslistener_fuzzer}/corpus/init (100%) rename test/servicesfuzztest/{softbus_listener_fuzzer => dmsoftbuslistener_fuzzer}/dm_softbus_listener_fuzzer.cpp (100%) rename test/servicesfuzztest/{softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h => dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.h} (100%) rename test/servicesfuzztest/{softbus_listener_fuzzer => dmsoftbuslistener_fuzzer}/project.xml (100%) diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn similarity index 100% rename from test/servicesfuzztest/softbus_listener_fuzzer/BUILD.gn rename to test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/corpus/init b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/corpus/init similarity index 100% rename from test/servicesfuzztest/softbus_listener_fuzzer/corpus/init rename to test/servicesfuzztest/dmsoftbuslistener_fuzzer/corpus/init diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp similarity index 100% rename from test/servicesfuzztest/softbus_listener_fuzzer/dm_softbus_listener_fuzzer.cpp rename to test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.h similarity index 100% rename from test/servicesfuzztest/softbus_listener_fuzzer/shift_lnn_gear_device_service_fuzzer.h rename to test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.h diff --git a/test/servicesfuzztest/softbus_listener_fuzzer/project.xml b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/project.xml similarity index 100% rename from test/servicesfuzztest/softbus_listener_fuzzer/project.xml rename to test/servicesfuzztest/dmsoftbuslistener_fuzzer/project.xml -- Gitee From 881d312cfffff9cbbc295b395c91fb7bcff3aab5 Mon Sep 17 00:00:00 2001 From: l30054665 Date: Tue, 27 May 2025 22:03:15 +0800 Subject: [PATCH 6/8] fuzz Signed-off-by: l30054665 --- .../dm_softbus_listener_fuzzer.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp index 69153252c..98206ce86 100644 --- a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp +++ b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp @@ -44,13 +44,11 @@ void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) deviceInfo.extraData = fdp.ConsumeRandomLengthString(); SoftbusListener::DeviceNameChange(deviceInfo); SoftbusListener::DeviceScreenStatusChange(deviceInfo); - int32_t errcode = fdp.ConsumeIntegral(); uint16_t deviceTypeId = fdp.ConsumeIntegral(); string proofInfoStr = fdp.ConsumeRandomLengthString(); SoftbusListener::CredentialAuthStatusProcess(proofInfoStr, deviceTypeId, errcode); - - const char* proofInfo = proofInfoStr.c_str(); + const char* proofInfo = proofInfoStr.c_str(); DevUserInfo localDevUserInfo; localDevUserInfo.deviceId = fdp.ConsumeRandomLengthString(); localDevUserInfo.userId = fdp.ConsumeIntegral(); @@ -59,13 +57,10 @@ void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) remoteDevUserInfo.userId = fdp.ConsumeIntegral(); string remoteAclList = fdp.ConsumeRandomLengthString(); SoftbusListener::OnSyncLocalAclList(localDevUserInfo, remoteDevUserInfo, remoteAclList); - string aclList = fdp.ConsumeRandomLengthString(); SoftbusListener::OnGetAclListHash(localDevUserInfo, remoteDevUserInfo, aclList); - uint32_t proofLen = fdp.ConsumeIntegral(); SoftbusListener::OnCredentialAuthStatus(proofInfo, proofLen, deviceTypeId, errcode); - uint16_t typeValue = fdp.ConsumeIntegral(); NodeStatusType type = static_cast(typeValue); NodeStatus status; @@ -73,24 +68,17 @@ void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) status.basicInfo.osType = fdp.ConsumeIntegral(); status.reserved[0] = fdp.ConsumeIntegral(); SoftbusListener::OnDeviceScreenStatusChanged(type, &status); - SoftbusListener listener; std::string networkIdStr = fdp.ConsumeRandomLengthString(); - const char* networkId = networkIdStr.c_str(); int32_t networkType = fdp.ConsumeIntegral(); - listener.GetNetworkTypeByNetworkId(networkId, networkType); - + listener.GetNetworkTypeByNetworkId(networkIdStr.c_str(), networkType); std::string name = fdp.ConsumeRandomLengthString(); SoftbusListener::CloseDmRadarHelperObj(name); - std::string msg = fdp.ConsumeRandomLengthString(); listener.SendAclChangedBroadcast(msg); - int32_t screenStatus = fdp.ConsumeIntegral(); listener.GetDeviceScreenStatus(networkId, screenStatus); - listener.DeleteCacheDeviceInfo(); - std::string displayName = fdp.ConsumeRandomLengthString(); listener.SetLocalDisplayName(displayName); } -- Gitee From d3ac2a79cbc300f33ee9e1a5a69aa82f59f69a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Tue, 27 May 2025 14:14:17 +0000 Subject: [PATCH 7/8] update test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp index 98206ce86..b50ca919e 100644 --- a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp +++ b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp @@ -35,7 +35,6 @@ void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) (size > DM_MAX_DEVICE_ID_LEN))) { return; } - FuzzedDataProvider fdp(data, size); DmDeviceInfo deviceInfo; deviceInfo.deviceTypeId = fdp.ConsumeIntegral(); -- Gitee From 7124049691695e02270ab5d3387fc108b3f96c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Tue, 27 May 2025 14:18:06 +0000 Subject: [PATCH 8/8] update test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp index b50ca919e..15fa538c3 100644 --- a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp +++ b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp @@ -78,8 +78,6 @@ void DmSoftbusListenerFuzzTest(const uint8_t* data, size_t size) int32_t screenStatus = fdp.ConsumeIntegral(); listener.GetDeviceScreenStatus(networkId, screenStatus); listener.DeleteCacheDeviceInfo(); - std::string displayName = fdp.ConsumeRandomLengthString(); - listener.SetLocalDisplayName(displayName); } } } -- Gitee