From 77e9a370af002118abeb42dee3bcf3532607da93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sun, 22 Jun 2025 18:40:35 +0800 Subject: [PATCH 1/3] add FUZZ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- test/BUILD.gn | 1 + test/commonfuzztest/BUILD.gn | 1 + .../dmnegotiateprocess_fuzzer/BUILD.gn | 80 ++++++++++++ .../dmnegotiateprocess_fuzzer/corpus/init | 13 ++ .../dm_negotiate_process_fuzzer.cpp | 79 ++++++++++++ .../dm_negotiate_process_fuzzer.h | 21 ++++ .../dmnegotiateprocess_fuzzer/project.xml | 25 ++++ test/jsonfuzztest/BUILD.gn | 20 +++ .../jsonobjectnlohmannjson_fuzzer/BUILD.gn | 63 ++++++++++ .../jsonobjectnlohmannjson_fuzzer/corpus/init | 13 ++ .../json_object_nlohmannjson_fuzzer.cpp | 70 +++++++++++ .../json_object_nlohmannjson_fuzzer.h | 21 ++++ .../jsonobjectnlohmannjson_fuzzer/project.xml | 25 ++++ .../devicenamemanager_fuzzer/BUILD.gn | 2 +- .../device_name_manager_fuzzer.cpp | 31 ++++- .../dm_transport_fuzzer.cpp | 39 +++--- .../softbus_connector_fuzzer.cpp | 101 ++++++++++++++- .../softbuslistener_fuzzer/project.xml | 2 +- .../softbus_listener_fuzzer.cpp | 115 +++++++++++++++++- 19 files changed, 693 insertions(+), 29 deletions(-) create mode 100644 test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn create mode 100644 test/commonfuzztest/dmnegotiateprocess_fuzzer/corpus/init create mode 100644 test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp create mode 100644 test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.h create mode 100644 test/commonfuzztest/dmnegotiateprocess_fuzzer/project.xml create mode 100644 test/jsonfuzztest/BUILD.gn create mode 100644 test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn create mode 100644 test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init create mode 100644 test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp create mode 100644 test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h create mode 100644 test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml diff --git a/test/BUILD.gn b/test/BUILD.gn index c856a29d0..f756c7a5e 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -20,6 +20,7 @@ group("test") { "benchmarktest:benchmarktest", "commonfuzztest:fuzztest", "interfacesfuzztest:fuzztest", + "jsonfuzztest:fuzztest", "servicesfuzztest:fuzztest", "softbusfuzztest:fuzztest", "unittest:unittest", diff --git a/test/commonfuzztest/BUILD.gn b/test/commonfuzztest/BUILD.gn index c88c67ba2..617816463 100644 --- a/test/commonfuzztest/BUILD.gn +++ b/test/commonfuzztest/BUILD.gn @@ -22,6 +22,7 @@ group("fuzztest") { "dmauthmanagerv2_fuzzer:fuzztest", "dmcommoneventmanager_fuzzer:fuzztest", "dmcredentialimpl_fuzzer:fuzztest", + "dmnegotiateprocess_fuzzer:fuzztest", "generateencrypteduuid_fuzzer:fuzztest", "getdeviceinfo_fuzzer:fuzztest", "hichainconnector_fuzzer:fuzztest", diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn b/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn new file mode 100644 index 000000000..1ce9887cd --- /dev/null +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn @@ -0,0 +1,80 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("//foundation/distributedhardware/device_manager/device_manager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("DmNegotiateProcessFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = + "${devicemanager_path}/test/commonfuzztest/dmnegotiateprocess_fuzzer" + + include_dirs = [ + "${innerkits_path}/native_cpp/include", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication_v2", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/timer", + ] + + cflags = [ + "-g", + "-O0", + "-Dprivate=public", + "-Dprotected=public", + "-Werror", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "dm_negotiate_process_fuzzer.cpp" ] + + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${services_path}:devicemanagerservicetest", + "${servicesimpl_path}:devicemanagerserviceimpl", + "${utils_path}:devicemanagerutilstest", + ] + + external_deps = [ + "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=\"DmNegotiateProcessFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":DmNegotiateProcessFuzzTest" ] +} +############################################################################### diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/corpus/init b/test/commonfuzztest/dmnegotiateprocess_fuzzer/corpus/init new file mode 100644 index 000000000..8f37f0925 --- /dev/null +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# 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. +FUZZ \ No newline at end of file diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp new file mode 100644 index 000000000..682875a33 --- /dev/null +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025-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 "dm_negotiate_process_fuzzer.h" + +#include +#include + +#include "device_manager_service_listener.h" +#include "dm_negotiate_process.h" + +namespace OHOS { +namespace DistributedHardware { + +void DmNegotiateProcessFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + std::shared_ptr context = std::make_shared(); + NoCredNoAclImportAuthType noCredNoAclImportAuthType; + noCredNoAclImportAuthType.NegotiateHandle(context); + NoCredNoAclInputAuthType noCredNoAclInputAuthType; + noCredNoAclInputAuthType.NegotiateHandle(context); + IdentCredNoAclImportAuthType identCredNoAclImportAuthType; + identCredNoAclImportAuthType.NegotiateHandle(context); + IdentCredNoAclInputAuthType identCredNoAclInputAuthType; + identCredNoAclInputAuthType.NegotiateHandle(context); + IdentCredIdentAclImportAuthType identCredIdentAclImportAuthType; + identCredIdentAclImportAuthType.NegotiateHandle(context); + IdentCredIdentAclInputAuthType identCredIdentAclInputAuthType; + identCredIdentAclInputAuthType.NegotiateHandle(context); + IdentCredP2pAclImportAuthType identCredP2pAclImportAuthType; + identCredP2pAclImportAuthType.NegotiateHandle(context); + IdentCredP2pAclInputAuthType identCredP2pAclInputAuthType; + identCredP2pAclInputAuthType.NegotiateHandle(context); + ShareCredNoAclImportAuthType shareCredNoAclImportAuthType; + shareCredNoAclImportAuthType.NegotiateHandle(context); + ShareCredNoAclInputAuthType shareCredNoAclInputAuthType; + shareCredNoAclInputAuthType.NegotiateHandle(context); + ShareCredShareAclImportAuthType shareCredShareAclImportAuthType; + shareCredShareAclImportAuthType.NegotiateHandle(context); + ShareCredShareAclInputAuthType shareCredShareAclInputAuthType; + shareCredShareAclInputAuthType.NegotiateHandle(context); + ShareCredP2pAclImportAuthType shareCredP2pAclImportAuthType; + shareCredP2pAclImportAuthType.NegotiateHandle(context); + ShareCredP2pAclInputAuthType shareCredP2pAclInputAuthType; + shareCredP2pAclInputAuthType.NegotiateHandle(context); + P2pCredNoAclImportAuthType p2pCredNoAclImportAuthType; + p2pCredNoAclImportAuthType.NegotiateHandle(context); + P2pCredNoAclInputAuthType p2pCredNoAclInputAuthType; + p2pCredNoAclInputAuthType.NegotiateHandle(context); + P2pCredP2pAclImportAuthType p2pCredP2pAclImportAuthType; + p2pCredP2pAclImportAuthType.NegotiateHandle(context); + P2pCredP2pAclInputAuthType p2pCredP2pAclInputAuthType; + p2pCredP2pAclInputAuthType.NegotiateHandle(context); +} +} // 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::DmNegotiateProcessFuzzTest(data, size); + return 0; +} \ No newline at end of file diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.h b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.h new file mode 100644 index 000000000..e79352fb8 --- /dev/null +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#ifndef DM_NEGOTIATE_PROCESS_FUZZER_H +#define DM_NEGOTIATE_PROCESS_FUZZER_H + +#define FUZZ_PROJECT_NAME "dmnegotiateprocess_fuzzer" + +#endif // DM_NEGOTIATE_PROCESS_FUZZER_H \ No newline at end of file diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/project.xml b/test/commonfuzztest/dmnegotiateprocess_fuzzer/project.xml new file mode 100644 index 000000000..500f6f414 --- /dev/null +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/jsonfuzztest/BUILD.gn b/test/jsonfuzztest/BUILD.gn new file mode 100644 index 000000000..bb5efd0aa --- /dev/null +++ b/test/jsonfuzztest/BUILD.gn @@ -0,0 +1,20 @@ +# 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. + +group("fuzztest") { + testonly = true + + deps = [ + "jsonobjectnlohmannjson_fuzzer:fuzztest", + ] +} diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn new file mode 100644 index 000000000..e90d83b3b --- /dev/null +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/BUILD.gn @@ -0,0 +1,63 @@ +# 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. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("//foundation/distributedhardware/device_manager/device_manager.gni") + +##############################fuzztest########################################## +ohos_fuzztest("JsonObjectNlohmannjsonFuzzTest") { + module_out_path = fuzz_test_output_path + fuzz_config_file = "${devicemanager_path}/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer" + + include_dirs = [ + "${common_path}/include", + "${json_path}/include", + ] + + cflags = [ + "-g", + "-O0", + "-Dprivate=public", + "-Dprotected=public", + "-Werror", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "json_object_nlohmannjson_fuzzer.cpp", + "${json_path}/src/json_object_cjson.cpp", ] + + deps = [] + + external_deps = [ + "cJSON:cjson", + "c_utils:utils", + "hilog:libhilog", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"JsonObjectNlohmannjsonFuzzTest\"", + "LOG_DOMAIN=0xD004110", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + + deps = [ ":JsonObjectNlohmannjsonFuzzTest" ] +} +############################################################################### diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init new file mode 100644 index 000000000..8f37f0925 --- /dev/null +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# 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. +FUZZ \ No newline at end of file diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp new file mode 100644 index 000000000..dbb463c0a --- /dev/null +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp @@ -0,0 +1,70 @@ +/* + * 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 "json_object_nlohmannjson_fuzzer.h" + +#include +#include +#include +#include + +#include "dm_constants.h" +#include "json_object.h" +namespace OHOS { +namespace DistributedHardware { + +void JsonObjectNlohmannjsonFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + JsonItemObject itemObject; + JsonItemObject itemObjectNew; + itemObject["key1"] = fdp.ConsumeIntegral(); + std::string str_value = fdp.ConsumeRandomLengthString(); + int16_t int16_value = fdp.ConsumeIntegral(); + double double_value = fdp.ConsumeFloatingPoint(); + bool bool_value = fdp.ConsumeBool(); + uint8_t uint8_value = fdp.ConsumeIntegral(); + uint16_t uint16_value = fdp.ConsumeIntegral(); + uint32_t uint32_value = fdp.ConsumeIntegral(); + int64_t int64_value = fdp.ConsumeIntegral(); + ToJson(itemObject, double_value); + ToJson(itemObject, int16_value); + FromJson(itemObject, double_value); + FromJson(itemObject, bool_value); + FromJson(itemObject, uint8_value); + FromJson(itemObject, uint16_value); + itemObject.IsNumber(); + itemObjectNew = itemObject; + itemObjectNew.PushBack(str_value); + itemObjectNew.PushBack(double_value); + itemObjectNew.PushBack(int64_value); + itemObjectNew.GetTo(double_value); + itemObjectNew.GetTo(uint32_value); + itemObjectNew.GetTo(bool_value); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::JsonObjectNlohmannjsonFuzzTest(data, size); + + return 0; +} diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h new file mode 100644 index 000000000..f01aa3031 --- /dev/null +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#ifndef JSON_OBJECT_NLOHMANNJSON_FUZZER_H +#define JSON_OBJECT_NLOHMANNJSON_FUZZER_H + +#define FUZZ_PROJECT_NAME "jsonobjectnlohmannjson_fuzzer" + +#endif // JSON_OBJECT_NLOHMANNJSON_FUZZER_H \ No newline at end of file diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml new file mode 100644 index 000000000..500f6f414 --- /dev/null +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + \ No newline at end of file diff --git a/test/servicesfuzztest/devicenamemanager_fuzzer/BUILD.gn b/test/servicesfuzztest/devicenamemanager_fuzzer/BUILD.gn index e769025ec..a129f111d 100644 --- a/test/servicesfuzztest/devicenamemanager_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicenamemanager_fuzzer/BUILD.gn @@ -63,7 +63,7 @@ ohos_fuzztest("DeviceNameManagerFuzzTest") { deps = [ "${devicemanager_path}/services/service:devicemanagerservice", - "${utils_path}:devicemanagerutils", + "${utils_path}:devicemanagerutilstest", ] defines = [ diff --git a/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp b/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp index d10be1a5f..34c66b67c 100644 --- a/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp +++ b/test/servicesfuzztest/devicenamemanager_fuzzer/device_name_manager_fuzzer.cpp @@ -13,24 +13,24 @@ * limitations under the License. */ +#include "device_name_manager_fuzzer.h" + #include #include +#include #include #include #include #include -#include -#include "device_name_manager_fuzzer.h" #include "device_name_manager.h" #include "dm_constants.h" - namespace OHOS { namespace DistributedHardware { namespace { - constexpr int32_t INT32_SIZE = 5; +constexpr int32_t INT32_SIZE = 5; } std::shared_ptr deviceNameMgr_ = std::make_shared(); @@ -105,8 +105,28 @@ void DeviceNameManagerFirstFuzzTest(const uint8_t* data, size_t size) std::shared_ptr helper = nullptr; deviceNameMgr_->ReleaseDataShareHelper(helper); } + +void DeviceNameManagerSecondFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr deviceNameMgr = std::make_shared(); + deviceNameMgr->UnInit(); + deviceNameMgr->GetUserDefinedDeviceName(); + std::string str; + deviceNameMgr->AnoyPrivacyString(str); + str = "1"; + deviceNameMgr->AnoyPrivacyString(str); + str = "1234"; + deviceNameMgr->AnoyPrivacyString(str); + str = fdp.ConsumeRandomLengthString(); + deviceNameMgr->AnoyPrivacyString(str); + deviceNameMgr->ConvertToWholeCharacter(str); } -} +} // namespace DistributedHardware +} // namespace OHOS /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) @@ -114,5 +134,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DistributedHardware::DeviceNameManagerFuzzTest(data, size); OHOS::DistributedHardware::DeviceNameManagerFirstFuzzTest(data, size); + OHOS::DistributedHardware::DeviceNameManagerSecondFuzzTest(data, size); return 0; } diff --git a/test/servicesfuzztest/dmtransport_fuzzer/dm_transport_fuzzer.cpp b/test/servicesfuzztest/dmtransport_fuzzer/dm_transport_fuzzer.cpp index 684e60ddd..f01ed0edf 100644 --- a/test/servicesfuzztest/dmtransport_fuzzer/dm_transport_fuzzer.cpp +++ b/test/servicesfuzztest/dmtransport_fuzzer/dm_transport_fuzzer.cpp @@ -13,17 +13,17 @@ * limitations under the License. */ +#include "dm_transport_fuzzer.h" + #include #include +#include #include #include #include -#include -#include "dm_transport.h" -#include "dm_transport_fuzzer.h" #include "dm_comm_tool.h" - +#include "dm_transport.h" namespace OHOS { namespace DistributedHardware { @@ -31,7 +31,6 @@ namespace DistributedHardware { std::shared_ptr dmCommToolPtr_ = std::make_shared(); std::shared_ptr dmTransPortPtr_ = std::make_shared(dmCommToolPtr_); - void DmTransPortFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -42,18 +41,16 @@ void DmTransPortFuzzTest(const uint8_t* data, size_t size) std::string rmtNetworkId(reinterpret_cast(data), size); std::string dmPkgName(reinterpret_cast(data), size); std::string peerSocketName(reinterpret_cast(data), size); - PeerSocketInfo info = { - .name = const_cast(peerSocketName.c_str()), + PeerSocketInfo info = { .name = const_cast(peerSocketName.c_str()), .networkId = const_cast(rmtNetworkId.c_str()), .pkgName = const_cast(dmPkgName.c_str()), - .dataType = DATA_TYPE_BYTES - }; + .dataType = DATA_TYPE_BYTES }; dmTransPortPtr_->OnSocketOpened(socketId, info); dmTransPortPtr_->OnSocketOpened(socketId, info); ShutdownReason reason = ShutdownReason::SHUTDOWN_REASON_LNN_CHANGED; dmTransPortPtr_->OnSocketClosed(socketId, reason); - void *dataInfo = nullptr; + void* dataInfo = nullptr; uint32_t dataLen = 0; dmTransPortPtr_->OnBytesReceived(socketId, dataInfo, dataLen); @@ -74,7 +71,7 @@ void DmTransPortFirstFuzzTest(const uint8_t* data, size_t size) if ((data == nullptr) || (size < sizeof(int32_t))) { return; } - + const char* jsonString = R"({ "MsgType": "0", "userId": "12345", @@ -95,12 +92,10 @@ void DmTransPortFirstFuzzTest(const uint8_t* data, size_t size) std::string rmtNetworkId(reinterpret_cast(data), size); std::string dmPkgName(reinterpret_cast(data), size); std::string peerSocketName(reinterpret_cast(data), size); - PeerSocketInfo info = { - .name = const_cast(peerSocketName.c_str()), + PeerSocketInfo info = { .name = const_cast(peerSocketName.c_str()), .networkId = const_cast(rmtNetworkId.c_str()), .pkgName = const_cast(dmPkgName.c_str()), - .dataType = DATA_TYPE_BYTES - }; + .dataType = DATA_TYPE_BYTES }; dmTransPortPtr_->OnSocketOpened(socketId, info); dmTransPortPtr_->HandleReceiveMessage(socketId, payload); dmTransPortPtr_->CreateClientSocket(rmtNetworkId); @@ -120,8 +115,19 @@ void DmTransPortFirstFuzzTest(const uint8_t* data, size_t size) std::string remoteDevId(reinterpret_cast(data), size); dmTransPortPtr_->ClearDeviceSocketOpened(remoteDevId, socketId); } + +void DmTransPortSecondFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + + std::shared_ptr dmCommToolPtr = std::make_shared(); + std::shared_ptr dmTransPortPtr = std::make_shared(dmCommToolPtr); + dmTransPortPtr->Init(); } -} +} // namespace DistributedHardware +} // namespace OHOS /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) @@ -129,5 +135,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DistributedHardware::DmTransPortFuzzTest(data, size); OHOS::DistributedHardware::DmTransPortFirstFuzzTest(data, size); + OHOS::DistributedHardware::DmTransPortSecondFuzzTest(data, size); return 0; } diff --git a/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp b/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp index 96704ebe8..384c7e601 100644 --- a/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp +++ b/test/softbusfuzztest/softbusconnector_fuzzer/softbus_connector_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -13,13 +13,16 @@ * limitations under the License. */ -#include "softbus_connector.h" -#include "softbus_bus_center.h" +#include "softbus_connector_fuzzer.h" + +#include + #include "dm_device_info.h" #include "dm_publish_info.h" #include "dm_subscribe_info.h" +#include "softbus_bus_center.h" +#include "softbus_connector.h" #include "softbus_session.h" -#include "softbus_connector_fuzzer.h" namespace OHOS { namespace DistributedHardware { @@ -36,6 +39,93 @@ void SoftBusConnectorFuzzTest(const uint8_t* data, size_t size) std::shared_ptr softbusConnector = std::make_shared(); softbusConnector->OnSoftbusJoinLNNResult(addr, networkId, result); } + +void SoftBusConnectorFirstFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + int32_t userId = fdp.ConsumeIntegral(); + std::string credId = fdp.ConsumeRandomLengthString(); + int32_t sessionKeyId = fdp.ConsumeIntegral(); + int32_t aclId = fdp.ConsumeIntegral(); + std::string localUdid = "localDeviceId"; + std::string remoteUdid = "remoteDeviceId"; + DistributedDeviceProfile::AccessControlProfile localAcl; + std::vector acLStrList; + std::string jsonString = fdp.ConsumeRandomLengthString(); + std::vector remoteAllAclList; + std::shared_ptr softbusConnector = std::make_shared(); + softbusConnector->SyncAclList(userId, credId, sessionKeyId, aclId); + DistributedDeviceProfile::Accesser acer; + DistributedDeviceProfile::Accessee acee; + acee.SetAccesseeDeviceId("localDeviceId"); + acer.SetAccesserDeviceId("remoteDeviceId"); + localAcl.SetTrustDeviceId("remoteDeviceId"); + localAcl.SetAccesser(acer); + localAcl.SetAccessee(acee); + softbusConnector->SyncLocalAclList5_1_0(localUdid, remoteUdid, localAcl, acLStrList); + acer.SetAccesserDeviceId("localDeviceId"); + acee.SetAccesseeDeviceId("remoteDeviceId"); + localAcl.SetTrustDeviceId("remoteDeviceId"); + localAcl.SetAccesser(acer); + localAcl.SetAccessee(acee); + softbusConnector->SyncLocalAclList5_1_0(localUdid, remoteUdid, localAcl, acLStrList); + softbusConnector->ParaseAclChecksumList(jsonString, remoteAllAclList); + std::string localVersion = fdp.ConsumeRandomLengthString(); + softbusConnector->GetLocalVersion(localUdid, remoteUdid, localVersion, localAcl); + std::vector aclVerDesc; + std::map remoteAllAclMap; + softbusConnector->SortAclListDesc(remoteAllAclList, aclVerDesc, remoteAllAclMap); + std::vector remoteVerDesc; + softbusConnector->MatchTargetVersion(localVersion, remoteVerDesc); + remoteVerDesc.push_back(fdp.ConsumeRandomLengthString()); + softbusConnector->MatchTargetVersion(localVersion, remoteVerDesc); + std::string deviceId = fdp.ConsumeRandomLengthString(); + std::string remoteUdidHash = fdp.ConsumeRandomLengthString(); + softbusConnector->JoinLnn(deviceId, remoteUdidHash); +} + +void SoftBusConnectorSecondFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr softbusConnector = std::make_shared(); + int32_t sessionId = fdp.ConsumeIntegral(); + int32_t sessionKeyId = fdp.ConsumeIntegral(); + std::string udid = fdp.ConsumeRandomLengthString(); + std::string udidHash = fdp.ConsumeRandomLengthString(); + int32_t remoteSessionKeyId = fdp.ConsumeIntegral(); + std::string deviceId = fdp.ConsumeRandomLengthString(); + softbusConnector->JoinLNNBySkId(sessionId, sessionKeyId, remoteSessionKeyId, udid, udidHash); + softbusConnector->JoinLnnByHml(sessionId, sessionKeyId, remoteSessionKeyId); + DeviceInfo deviceInfo; + DmDeviceInfo dmDeviceInfo; + memcpy_s(deviceInfo.devId, sizeof(deviceInfo.devId), "deviceId", sizeof("deviceId")); + memcpy_s(deviceInfo.devName, sizeof(deviceInfo.devName), "deviceName", sizeof("deviceName")); + softbusConnector->ConvertDeviceInfoToDmDevice(deviceInfo, dmDeviceInfo); + DmDeviceBasicInfo dmDeviceBasicInfo; + softbusConnector->ConvertDeviceInfoToDmDevice(deviceInfo, dmDeviceBasicInfo); + softbusConnector->GetLocalDeviceNetworkId(); + ProcessInfo processInfo; + softbusConnector->SetProcessInfo(processInfo); + std::vector processInfoVec; + softbusConnector->SetProcessInfoVec(processInfoVec); + softbusConnector->GetProcessInfo(); + softbusConnector->ClearProcessInfo(); + softbusConnector->SetChangeProcessInfo(processInfo); + softbusConnector->GetChangeProcessInfo(); + softbusConnector->ClearChangeProcessInfo(); + softbusConnector->DeleteOffLineTimer(udidHash); + softbusConnector->CheckIsNeedJoinLnn(udid, deviceId); + NodeBasicInfo nodeBasicInfo; + memcpy_s(nodeBasicInfo.networkId, sizeof(nodeBasicInfo.networkId), "networkId", sizeof("networkId")); + memcpy_s(nodeBasicInfo.deviceName, sizeof(nodeBasicInfo.deviceName), "deviceName", sizeof("deviceName")); + softbusConnector->ConvertNodeBasicInfoToDmDevice(nodeBasicInfo, dmDeviceInfo); +} } } @@ -44,6 +134,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { /* Run your code on data */ OHOS::DistributedHardware::SoftBusConnectorFuzzTest(data, size); - + OHOS::DistributedHardware::SoftBusConnectorFirstFuzzTest(data, size); + OHOS::DistributedHardware::SoftBusConnectorSecondFuzzTest(data, size); return 0; } diff --git a/test/softbusfuzztest/softbuslistener_fuzzer/project.xml b/test/softbusfuzztest/softbuslistener_fuzzer/project.xml index 500f6f414..ed4f3e9e5 100644 --- a/test/softbusfuzztest/softbuslistener_fuzzer/project.xml +++ b/test/softbusfuzztest/softbuslistener_fuzzer/project.xml @@ -18,7 +18,7 @@ 1000 - 300 + 10 4096 diff --git a/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp b/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp index 7041f169d..1647e8ed3 100644 --- a/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp +++ b/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp @@ -283,6 +283,117 @@ void SoftBusListenerForthFuzzTest(const uint8_t* data, size_t size) std::vector deviceList; softbusListener_->GetAllTrustedDeviceList(pkgName, extra, deviceList); } + +void SoftBusListenerFifthFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + DmDeviceInfo deviceInfo; + softbusListener_->InitSoftbusListener(); + softbusListener_->DeviceOnLine(deviceInfo); + softbusListener_->DeviceOffLine(deviceInfo); + softbusListener_->DeviceNameChange(deviceInfo); + std::string msg = fdp.ConsumeRandomLengthString(); + softbusListener_->DeviceNotTrust(msg); + softbusListener_->DeviceScreenStatusChange(deviceInfo); + std::string deviceList = fdp.ConsumeRandomLengthString(); + int32_t errcode = fdp.ConsumeIntegral(); + uint16_t deviceTypeId = fdp.ConsumeIntegral(); + softbusListener_->CredentialAuthStatusProcess(deviceList, deviceTypeId, errcode); + DevUserInfo localDevUserInfo; + DevUserInfo remoteDevUserInfo; + std::string remoteAclList = fdp.ConsumeRandomLengthString(); + softbusListener_->OnSyncLocalAclList(localDevUserInfo, remoteDevUserInfo, remoteAclList); + std::string aclList = fdp.ConsumeRandomLengthString(); + softbusListener_->OnGetAclListHash(localDevUserInfo, remoteDevUserInfo, aclList); + uint32_t deviceListLen = static_cast(deviceList.length()); + softbusListener_->OnCredentialAuthStatus(deviceList.data(), deviceListLen, deviceTypeId, errcode); + std::shared_ptr info = nullptr; + softbusListener_->UpdateDeviceName(info.get()); + info = std::make_shared(); + softbusListener_->UpdateDeviceName(info.get()); + int32_t publishId = fdp.ConsumeIntegral(); + softbusListener_->StopPublishSoftbusLNN(publishId); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::shared_ptr callback; + softbusListener_->RegisterSoftbusLnnOpsCbk(pkgName, callback); + callback = std::make_shared(); + softbusListener_->RegisterSoftbusLnnOpsCbk(pkgName, callback); + softbusListener_->UnRegisterSoftbusLnnOpsCbk(pkgName); + std::string networkId = fdp.ConsumeRandomLengthString(); + softbusListener_->GetDeviceInfo(networkId, deviceInfo); + std::string udid = fdp.ConsumeRandomLengthString(); + softbusListener_->GetNetworkIdByUdid(udid, networkId); + std::string deviceName = fdp.ConsumeRandomLengthString(); + softbusListener_->GetDeviceNameByUdid(udid, deviceName); + bool isWakeUp = fdp.ConsumeBool(); + std::string callerId = fdp.ConsumeRandomLengthString(); + softbusListener_->ShiftLNNGear(isWakeUp, callerId); +} + +void SoftBusListenerSixthFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + DmDeviceInfo deviceInfo; + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string networkId = fdp.ConsumeRandomLengthString(); + std::string msg = fdp.ConsumeRandomLengthString(); + uint8_t arr[DATA_LEN] = { 1 }; + size_t len = static_cast(DATA_LEN); + softbusListener_->ConvertBytesToUpperCaseHexString(arr, len); + int32_t networkType = fdp.ConsumeIntegral(); + softbusListener_->GetNetworkTypeByNetworkId(networkId.data(), networkType); + int32_t securityLevel = fdp.ConsumeIntegral(); + softbusListener_->GetDeviceSecurityLevel(networkId.data(), securityLevel); + std::string name = fdp.ConsumeRandomLengthString(); + softbusListener_->CloseDmRadarHelperObj(name); + std::string deviceId = fdp.ConsumeRandomLengthString(); + std::string ip = fdp.ConsumeRandomLengthString(); + ConnectionAddrType addrType = ConnectionAddrType::CONNECTION_ADDR_ETH; + softbusListener_->GetIPAddrTypeFromCache(deviceId, ip, addrType); + softbusListener_->SendAclChangedBroadcast(msg); + softbusListener_->GetSoftbusRefreshCb(); + int32_t screenStatus = fdp.ConsumeIntegral(); + softbusListener_->GetDeviceScreenStatus(networkId.data(), screenStatus); + std::string remoteUserId = fdp.ConsumeRandomLengthString(); + std::vector userIds; + softbusListener_->SetForegroundUserIdsToDSoftBus(remoteUserId, userIds); + softbusListener_->DeleteCacheDeviceInfo(); + std::string displayName = fdp.ConsumeRandomLengthString(); + softbusListener_->SetLocalDisplayName(displayName); + DistributedDeviceProfile::AccessControlProfile profile; + softbusListener_->ConvertAclToDeviceInfo(profile, deviceInfo); + std::string extra = fdp.ConsumeRandomLengthString(); + std::vector devList; + softbusListener_->GetAllTrustedDeviceList(pkgName, extra, devList); + std::shared_ptr customDataJson = std::make_shared(); + int32_t actionId = fdp.ConsumeIntegral(); + softbusListener_->GetAttrFromCustomData(customDataJson.get(), deviceInfo, actionId); +} + +void SoftBusListenerSeventhFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + NodeBasicInfo nodeBasicInfo = { .networkId = { "networkId" }, + .deviceName = { "deviceNameInfo" }, + .deviceTypeId = 1, + .osType = 1, + .osVersion = "onVersion" }; + int32_t devScreenStatus = fdp.ConsumeIntegral(); + DmDeviceInfo devInfo; + softbusListener_->ConvertScreenStatusToDmDevice(nodeBasicInfo, devScreenStatus, devInfo); + softbusListener_->ConvertNodeBasicInfoToDmDevice(nodeBasicInfo, devInfo); + DmDeviceBasicInfo dmdevInfo; + softbusListener_->ConvertNodeBasicInfoToDmDevice(nodeBasicInfo, dmdevInfo); +} } } @@ -295,6 +406,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::DistributedHardware::SoftBusListenerSecondFuzzTest(data, size); OHOS::DistributedHardware::SoftBusListenerThirdFuzzTest(data, size); OHOS::DistributedHardware::SoftBusListenerForthFuzzTest(data, size); - + OHOS::DistributedHardware::SoftBusListenerFifthFuzzTest(data, size); + OHOS::DistributedHardware::SoftBusListenerSixthFuzzTest(data, size); + OHOS::DistributedHardware::SoftBusListenerSeventhFuzzTest(data, size); return 0; } -- Gitee From 031efc4ee1b6c23450e9287e5f09dce7180384da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sun, 22 Jun 2025 18:54:02 +0800 Subject: [PATCH 2/3] add FUZZ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- .../json_object_nlohmannjson_fuzzer.cpp | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp index dbb463c0a..01b307c11 100644 --- a/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp +++ b/test/jsonfuzztest/jsonobjectnlohmannjson_fuzzer/json_object_nlohmannjson_fuzzer.cpp @@ -34,28 +34,28 @@ void JsonObjectNlohmannjsonFuzzTest(const uint8_t* data, size_t size) JsonItemObject itemObject; JsonItemObject itemObjectNew; itemObject["key1"] = fdp.ConsumeIntegral(); - std::string str_value = fdp.ConsumeRandomLengthString(); - int16_t int16_value = fdp.ConsumeIntegral(); - double double_value = fdp.ConsumeFloatingPoint(); - bool bool_value = fdp.ConsumeBool(); - uint8_t uint8_value = fdp.ConsumeIntegral(); - uint16_t uint16_value = fdp.ConsumeIntegral(); - uint32_t uint32_value = fdp.ConsumeIntegral(); - int64_t int64_value = fdp.ConsumeIntegral(); - ToJson(itemObject, double_value); - ToJson(itemObject, int16_value); - FromJson(itemObject, double_value); - FromJson(itemObject, bool_value); - FromJson(itemObject, uint8_value); - FromJson(itemObject, uint16_value); + std::string strValue = fdp.ConsumeRandomLengthString(); + int16_t int16Value = fdp.ConsumeIntegral(); + double doubleValue = fdp.ConsumeFloatingPoint(); + bool boolValue = fdp.ConsumeBool(); + uint8_t uint8Value = fdp.ConsumeIntegral(); + uint16_t uint16Value = fdp.ConsumeIntegral(); + uint32_t uint32Value = fdp.ConsumeIntegral(); + int64_t int64Value = fdp.ConsumeIntegral(); + ToJson(itemObject, doubleValue); + ToJson(itemObject, int16Value); + FromJson(itemObject, doubleValue); + FromJson(itemObject, boolValue); + FromJson(itemObject, uint8Value); + FromJson(itemObject, uint16Value); itemObject.IsNumber(); itemObjectNew = itemObject; - itemObjectNew.PushBack(str_value); - itemObjectNew.PushBack(double_value); - itemObjectNew.PushBack(int64_value); - itemObjectNew.GetTo(double_value); - itemObjectNew.GetTo(uint32_value); - itemObjectNew.GetTo(bool_value); + itemObjectNew.PushBack(strValue); + itemObjectNew.PushBack(doubleValue); + itemObjectNew.PushBack(int64Value); + itemObjectNew.GetTo(doubleValue); + itemObjectNew.GetTo(uint32Value); + itemObjectNew.GetTo(boolValue); } } } -- Gitee From 0bae8f36f8c40fd94215c4ee3a604d40d6b2b9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sun, 22 Jun 2025 19:02:20 +0800 Subject: [PATCH 3/3] add FUZZ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- .../softbuslistener_fuzzer/softbus_listener_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp b/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp index 1647e8ed3..bdce67ed3 100644 --- a/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp +++ b/test/softbusfuzztest/softbuslistener_fuzzer/softbus_listener_fuzzer.cpp @@ -302,7 +302,7 @@ void SoftBusListenerFifthFuzzTest(const uint8_t* data, size_t size) int32_t errcode = fdp.ConsumeIntegral(); uint16_t deviceTypeId = fdp.ConsumeIntegral(); softbusListener_->CredentialAuthStatusProcess(deviceList, deviceTypeId, errcode); - DevUserInfo localDevUserInfo; + DevUserInfo localDevUserInfo; DevUserInfo remoteDevUserInfo; std::string remoteAclList = fdp.ConsumeRandomLengthString(); softbusListener_->OnSyncLocalAclList(localDevUserInfo, remoteDevUserInfo, remoteAclList); -- Gitee