From 13c24e1122f19ffd5cdc969fa41f11bce3d5add3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 06:35:16 +0000 Subject: [PATCH 01/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- services/implementation/src/attest/dm_auth_attest_common.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/implementation/src/attest/dm_auth_attest_common.cpp b/services/implementation/src/attest/dm_auth_attest_common.cpp index deec44d10..5765e816c 100644 --- a/services/implementation/src/attest/dm_auth_attest_common.cpp +++ b/services/implementation/src/attest/dm_auth_attest_common.cpp @@ -120,6 +120,10 @@ bool AuthAttestCommon::DeserializeDmCertChain(const std::string &data, DmCertCha JsonObject jsonObject; jsonObject.Parse(data); const uint32_t certCount = jsonObject[TAG_CERT_COUNT].Get(); + if (certCount > MAX_CERT_COUNT) { + LOGE("Invalid certCount too large"); + return false; + } JsonObject jsonArrayObj(JsonCreateType::JSON_CREATE_TYPE_ARRAY); jsonArrayObj.Parse(jsonObject[TAG_CERT].Dump()); DmBlob *certs = new DmBlob[certCount]; -- Gitee From 04fb0332a921d821e9faee1540e83588f04296d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 07:23:59 +0000 Subject: [PATCH 02/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- common/src/dm_anonymous.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 57edca138..aeabd2c57 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -31,25 +31,25 @@ const int32_t LIST_SPLIT_LEN = 2; std::string GetAnonyString(const std::string &value) { - const int32_t INT32_SHORT_ID_LENGTH = 20; - const int32_t INT32_PLAINTEXT_LENGTH = 4; - const int32_t INT32_MIN_ID_LENGTH = 3; + const int32_t int32ShortIdLength = 20; + const int32_t int32PlaintextLength = 4; + const int32_t int32MinIdLength = 3; std::string tmpStr("******"); size_t strLen = value.length(); - if (strLen < INT32_MIN_ID_LENGTH) { + if (strLen < int32MinIdLength) { return tmpStr; } std::string res; - if (strLen <= INT32_SHORT_ID_LENGTH) { + if (strLen <= int32ShortIdLength) { res += value[0]; res += tmpStr; res += value[strLen - 1]; } else { - res.append(value, 0, INT32_PLAINTEXT_LENGTH); + res.append(value, 0, int32PlaintextLength); res += tmpStr; - res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); + res.append(value, strLen - int32PlaintextLength, int32PlaintextLength); } return res; @@ -105,11 +105,11 @@ bool IsNumberString(const std::string &inputString) LOGE("inputString is Null or inputString length is too long"); return false; } - const int32_t MIN_ASCII_NUM = 48; - const int32_t MAX_ASCII_NUM = 57; + const int32_t minAsciiNum = 48; + const int32_t maxAsciiNum = 57; for (size_t i = 0; i < inputString.length(); i++) { int num = (int)inputString[i]; - if (num >= MIN_ASCII_NUM && num <= MAX_ASCII_NUM) { + if (num >= minAsciiNum && num <= maxAsciiNum) { continue; } else { return false; -- Gitee From c74cc90d05594534390a2080d13551da3e406d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 07:42:46 +0000 Subject: [PATCH 03/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/commonunittest/UTTest_dm_anonymous.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/commonunittest/UTTest_dm_anonymous.cpp b/test/commonunittest/UTTest_dm_anonymous.cpp index 8be86ff7e..09bb25317 100644 --- a/test/commonunittest/UTTest_dm_anonymous.cpp +++ b/test/commonunittest/UTTest_dm_anonymous.cpp @@ -431,15 +431,15 @@ HWTEST_F(DmAnonymousTest, IsBool_002, testing::ext::TestSize.Level1) */ HWTEST_F(DmAnonymousTest, ConvertCharArray2String_001, testing::ext::TestSize.Level1) { - constexpr uint32_t MAX_MESSAGE_LEN = 40 * 1024 * 1024; + constexpr uint32_t maxMessageLen = 40 * 1024 * 1024; char *srcData = nullptr; uint32_t srcLen = 0; std::string ret = ConvertCharArray2String(srcData, srcLen); EXPECT_EQ(ret, ""); - ret = ConvertCharArray2String(srcData, MAX_MESSAGE_LEN + 1); + ret = ConvertCharArray2String(srcData, maxMessageLen + 1); EXPECT_EQ(ret, ""); char srcData2[20] = {"1234"}; - ret = ConvertCharArray2String(srcData2, MAX_MESSAGE_LEN + 1); + ret = ConvertCharArray2String(srcData2, maxMessageLen + 1); EXPECT_EQ(ret, ""); uint32_t srcLen2 = 20; ret = ConvertCharArray2String(srcData2, srcLen); -- Gitee From dcb9fae3c893128b729650ab74e330776b82df68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:06:22 +0000 Subject: [PATCH 04/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- interfaces/kits/ndk/include/oh_device_manager_err_code.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/ndk/include/oh_device_manager_err_code.h b/interfaces/kits/ndk/include/oh_device_manager_err_code.h index cd33a88fe..0cf3c61d6 100644 --- a/interfaces/kits/ndk/include/oh_device_manager_err_code.h +++ b/interfaces/kits/ndk/include/oh_device_manager_err_code.h @@ -47,7 +47,7 @@ extern "C" { * * @since 20 */ -typedef enum DeviceManager_ErrorCode { +typedef enum DeviceManagerErrorCode { /** * @error The operation is successful. */ @@ -72,7 +72,7 @@ typedef enum DeviceManager_ErrorCode { * @error Failed to obtain the bundleName. */ DM_ERR_OBTAIN_BUNDLE_NAME = 11600109, -} DeviceManager_ErrorCode; +} DeviceManagerErrorCode; #ifdef __cplusplus }; #endif -- Gitee From 7b88d949d34da80f6ef8145add864afc803841ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:07:10 +0000 Subject: [PATCH 05/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- interfaces/kits/ndk/include/oh_device_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/ndk/include/oh_device_manager.h b/interfaces/kits/ndk/include/oh_device_manager.h index e4218188e..a3b262ec0 100644 --- a/interfaces/kits/ndk/include/oh_device_manager.h +++ b/interfaces/kits/ndk/include/oh_device_manager.h @@ -49,7 +49,7 @@ extern "C" { * @param localDeviceName This is an output parameter. It indicates the address pointer of the localDeviceName. * You need to manually release space resources after using. * @param len This is an output parameter. Length of the localDeviceName. - * @return Returns the status code of the execution. For detail, see {@link DeviceManager_ErrorCode}. + * @return Returns the status code of the execution. For detail, see {@link DeviceManagerErrorCode}. * Returns {@link ERR_OK}, The operation is successful. * Returns {@link DM_ERR_FAILED}, Failed to execute the function. * Returns {@link DM_ERR_OBTAIN_SERVICE}, Failed to obtain devicemanager service. -- Gitee From f3d85e0ca7202d5adbed2e9395e0fb4423f33d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:14:50 +0000 Subject: [PATCH 06/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../device_manager_impl_fuzzer.cpp | 525 +++++++++--------- 1 file changed, 262 insertions(+), 263 deletions(-) diff --git a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp index 69cebe8cf..5988b4d5b 100755 --- a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp +++ b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/device_manager_impl_fuzzer.cpp @@ -1,265 +1,264 @@ /* - * 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. - */ +* 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 - #include - #include - - #include "device_manager_impl.h" - - namespace OHOS { - namespace DistributedHardware { - - namespace { - - } - - void StopAuthenticateDeviceTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().StopAuthenticateDevice(pkgName); - DeviceManagerImpl::GetInstance().OnDmServiceDied(); - } - - void UnBindDeviceTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string deviceId = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().UnBindDevice(pkgName, deviceId); - } - - void ShiftLNNGearTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().ShiftLNNGear(pkgName); - } - - void RegDevTrustChangeCallbackTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::shared_ptr callback = nullptr; - std::string pkgName = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().RegDevTrustChangeCallback(pkgName, callback); - } - - void GetNetworkIdByUdidTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string udid = fdp.ConsumeRandomLengthString(); - std::string networkId = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().GetNetworkIdByUdid(pkgName, udid, networkId); - } - - void RegisterCredentialAuthStatusCallbackTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().RegisterCredentialAuthStatusCallback(pkgName, callback); - } - - void GetAllTrustedDeviceListTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string extra = fdp.ConsumeRandomLengthString(); - std::vector deviceList; - DeviceManagerImpl::GetInstance().GetAllTrustedDeviceList(pkgName, extra, deviceList); - } - - void RegisterSinkBindCallbackTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().RegisterSinkBindCallback(pkgName, callback); - } - - void GetDeviceProfileInfoListTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DmDeviceProfileInfoFilterOptions filterOptions; - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().GetDeviceProfileInfoList(pkgName, filterOptions, callback); - } - - void GetDeviceIconInfoTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DmDeviceProfileInfoFilterOptions filterOptions; - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().GetDeviceProfileInfoList(pkgName, filterOptions, callback); - } - - void PutDeviceProfileInfoListTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::vector deviceProfileInfoList; - DeviceManagerImpl::GetInstance().PutDeviceProfileInfoList(pkgName, deviceProfileInfoList); - } - - void GetLocalDisplayDeviceNameTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string displayName = fdp.ConsumeRandomLengthString(); - int32_t maxNameLength = fdp.ConsumeIntegral(); - DeviceManagerImpl::GetInstance().GetLocalDisplayDeviceName(pkgName, maxNameLength, displayName); - } - - void GetDeviceNetworkIdListTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string bundleName = fdp.ConsumeRandomLengthString(); - NetworkIdQueryFilter queryFilter; - std::vector networkIds; - DeviceManagerImpl::GetInstance().GetDeviceNetworkIdList(bundleName, queryFilter, networkIds); - } - - void SetLocalDeviceNameTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string deviceName = fdp.ConsumeRandomLengthString(); - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().SetLocalDeviceName(pkgName, deviceName, callback); - } - - void SetRemoteDeviceNameTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - std::string deviceId = fdp.ConsumeRandomLengthString(); - std::string deviceName = fdp.ConsumeRandomLengthString(); - std::shared_ptr callback = nullptr; - DeviceManagerImpl::GetInstance().SetRemoteDeviceName(pkgName, deviceId, deviceName, callback); - } - - void RestoreLocalDeviceNameTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().RestoreLocalDeviceName(pkgName); - } - - void GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string bundleName = fdp.ConsumeRandomLengthString(); - int32_t maxNameLength = fdp.ConsumeIntegral(); - DMLocalServiceInfo info; - DeviceManagerImpl::GetInstance(). - GetLocalServiceInfoByBundleNameAndPinExchangeType(bundleName, maxNameLength, info); - } - - void UnRegisterPinHolderCallbackTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return; - } - FuzzedDataProvider fdp(data, size); - std::string pkgName = fdp.ConsumeRandomLengthString(); - DeviceManagerImpl::GetInstance().UnRegisterPinHolderCallback(pkgName); - } - } - } - - /* Fuzzer entry point */ - extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) - { - /* Run your code on data */ - OHOS::DistributedHardware::StopAuthenticateDeviceTest(data, size); - OHOS::DistributedHardware::UnBindDeviceTest(data, size); - OHOS::DistributedHardware::ShiftLNNGearTest(data, size); - OHOS::DistributedHardware::RegDevTrustChangeCallbackTest(data, size); - OHOS::DistributedHardware::GetNetworkIdByUdidTest(data, size); - OHOS::DistributedHardware::RegisterCredentialAuthStatusCallbackTest(data, size); - OHOS::DistributedHardware::GetAllTrustedDeviceListTest(data, size); - OHOS::DistributedHardware::RegisterSinkBindCallbackTest(data, size); - OHOS::DistributedHardware::GetDeviceProfileInfoListTest(data, size); - OHOS::DistributedHardware::GetDeviceIconInfoTest(data, size); - OHOS::DistributedHardware::PutDeviceProfileInfoListTest(data, size); - OHOS::DistributedHardware::GetLocalDisplayDeviceNameTest(data, size); - OHOS::DistributedHardware::GetDeviceNetworkIdListTest(data, size); - OHOS::DistributedHardware::SetLocalDeviceNameTest(data, size); - OHOS::DistributedHardware::SetRemoteDeviceNameTest(data, size); - OHOS::DistributedHardware::RestoreLocalDeviceNameTest(data, size); - OHOS::DistributedHardware::GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(data, size); - OHOS::DistributedHardware::UnRegisterPinHolderCallbackTest(data, size); - return 0; - } - \ No newline at end of file +#include +#include +#include +#include +#include +#include +#include + +#include "device_manager_impl.h" + +namespace OHOS { +namespace DistributedHardware { + +namespace { + +} + +void StopAuthenticateDeviceTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().StopAuthenticateDevice(pkgName); + DeviceManagerImpl::GetInstance().OnDmServiceDied(); +} + +void UnBindDeviceTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string deviceId = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().UnBindDevice(pkgName, deviceId); +} + +void ShiftLNNGearTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().ShiftLNNGear(pkgName); +} + +void RegDevTrustChangeCallbackTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr callback = nullptr; + std::string pkgName = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().RegDevTrustChangeCallback(pkgName, callback); +} + +void GetNetworkIdByUdidTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string udid = fdp.ConsumeRandomLengthString(); + std::string networkId = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().GetNetworkIdByUdid(pkgName, udid, networkId); +} + +void RegisterCredentialAuthStatusCallbackTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().RegisterCredentialAuthStatusCallback(pkgName, callback); +} + +void GetAllTrustedDeviceListTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string extra = fdp.ConsumeRandomLengthString(); + std::vector deviceList; + DeviceManagerImpl::GetInstance().GetAllTrustedDeviceList(pkgName, extra, deviceList); +} + +void RegisterSinkBindCallbackTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().RegisterSinkBindCallback(pkgName, callback); +} + +void GetDeviceProfileInfoListTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DmDeviceProfileInfoFilterOptions filterOptions; + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().GetDeviceProfileInfoList(pkgName, filterOptions, callback); +} + +void GetDeviceIconInfoTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DmDeviceProfileInfoFilterOptions filterOptions; + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().GetDeviceProfileInfoList(pkgName, filterOptions, callback); +} + +void PutDeviceProfileInfoListTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::vector deviceProfileInfoList; + DeviceManagerImpl::GetInstance().PutDeviceProfileInfoList(pkgName, deviceProfileInfoList); +} + +void GetLocalDisplayDeviceNameTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string displayName = fdp.ConsumeRandomLengthString(); + int32_t maxNameLength = fdp.ConsumeIntegral(); + DeviceManagerImpl::GetInstance().GetLocalDisplayDeviceName(pkgName, maxNameLength, displayName); +} + +void GetDeviceNetworkIdListTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string bundleName = fdp.ConsumeRandomLengthString(); + NetworkIdQueryFilter queryFilter; + std::vector networkIds; + DeviceManagerImpl::GetInstance().GetDeviceNetworkIdList(bundleName, queryFilter, networkIds); +} + +void SetLocalDeviceNameTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string deviceName = fdp.ConsumeRandomLengthString(); + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().SetLocalDeviceName(pkgName, deviceName, callback); +} + +void SetRemoteDeviceNameTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + std::string deviceId = fdp.ConsumeRandomLengthString(); + std::string deviceName = fdp.ConsumeRandomLengthString(); + std::shared_ptr callback = nullptr; + DeviceManagerImpl::GetInstance().SetRemoteDeviceName(pkgName, deviceId, deviceName, callback); +} + +void RestoreLocalDeviceNameTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().RestoreLocalDeviceName(pkgName); +} + +void GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string bundleName = fdp.ConsumeRandomLengthString(); + int32_t maxNameLength = fdp.ConsumeIntegral(); + DMLocalServiceInfo info; + DeviceManagerImpl::GetInstance(). + GetLocalServiceInfoByBundleNameAndPinExchangeType(bundleName, maxNameLength, info); +} + +void UnRegisterPinHolderCallbackTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size == 0)) { + return; + } + FuzzedDataProvider fdp(data, size); + std::string pkgName = fdp.ConsumeRandomLengthString(); + DeviceManagerImpl::GetInstance().UnRegisterPinHolderCallback(pkgName); +} +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::DistributedHardware::StopAuthenticateDeviceTest(data, size); + OHOS::DistributedHardware::UnBindDeviceTest(data, size); + OHOS::DistributedHardware::ShiftLNNGearTest(data, size); + OHOS::DistributedHardware::RegDevTrustChangeCallbackTest(data, size); + OHOS::DistributedHardware::GetNetworkIdByUdidTest(data, size); + OHOS::DistributedHardware::RegisterCredentialAuthStatusCallbackTest(data, size); + OHOS::DistributedHardware::GetAllTrustedDeviceListTest(data, size); + OHOS::DistributedHardware::RegisterSinkBindCallbackTest(data, size); + OHOS::DistributedHardware::GetDeviceProfileInfoListTest(data, size); + OHOS::DistributedHardware::GetDeviceIconInfoTest(data, size); + OHOS::DistributedHardware::PutDeviceProfileInfoListTest(data, size); + OHOS::DistributedHardware::GetLocalDisplayDeviceNameTest(data, size); + OHOS::DistributedHardware::GetDeviceNetworkIdListTest(data, size); + OHOS::DistributedHardware::SetLocalDeviceNameTest(data, size); + OHOS::DistributedHardware::SetRemoteDeviceNameTest(data, size); + OHOS::DistributedHardware::RestoreLocalDeviceNameTest(data, size); + OHOS::DistributedHardware::GetLocalServiceInfoByBundleNameAndPinExchangeTypeTest(data, size); + OHOS::DistributedHardware::UnRegisterPinHolderCallbackTest(data, size); + return 0; +} -- Gitee From c0d600c150e6519d5785512a266977943ed27fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:17:53 +0000 Subject: [PATCH 07/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_dm_pin_holder.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unittest/UTTest_dm_pin_holder.h b/test/unittest/UTTest_dm_pin_holder.h index 3b3746bab..547e5717e 100644 --- a/test/unittest/UTTest_dm_pin_holder.h +++ b/test/unittest/UTTest_dm_pin_holder.h @@ -216,14 +216,14 @@ public: (void)processInfo; } - virtual void OnDevStateCallbackAdd(const ProcessInfo &processInfo, + void OnDevStateCallbackAdd(const ProcessInfo &processInfo, const std::vector &deviceList) override { (void)processInfo; (void)deviceList; } - virtual void OnGetDeviceProfileInfoListResult(const ProcessInfo &processInfo, + void OnGetDeviceProfileInfoListResult(const ProcessInfo &processInfo, const std::vector &deviceProfileInfos, int32_t code) override { (void)processInfo; @@ -231,7 +231,7 @@ public: (void)code; } - virtual void OnGetDeviceIconInfoResult(const ProcessInfo &processInfo, + void OnGetDeviceIconInfoResult(const ProcessInfo &processInfo, const DmDeviceIconInfo &dmDeviceIconInfo, int32_t code) override { (void)processInfo; @@ -239,7 +239,7 @@ public: (void)code; } - virtual void OnSetLocalDeviceNameResult(const ProcessInfo &processInfo, + void OnSetLocalDeviceNameResult(const ProcessInfo &processInfo, const std::string &deviceName, int32_t code) override { (void)processInfo; @@ -247,7 +247,7 @@ public: (void)code; } - virtual void OnSetRemoteDeviceNameResult(const ProcessInfo &processInfo, const std::string &deviceId, + void OnSetRemoteDeviceNameResult(const ProcessInfo &processInfo, const std::string &deviceId, const std::string &deviceName, int32_t code) override { (void)processInfo; -- Gitee From a9eee023f0a92ce32dbe73f3e57b958454185b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:21:24 +0000 Subject: [PATCH 08/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../UTTest_dm_auth_manager_first.cpp | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/test/commonunittest/UTTest_dm_auth_manager_first.cpp b/test/commonunittest/UTTest_dm_auth_manager_first.cpp index 887ebd6e8..aff6cb61d 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_first.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_first.cpp @@ -1490,34 +1490,6 @@ HWTEST_F(DmAuthManagerTest, StopAuthenticateDevice_001, testing::ext::TestSize.L ASSERT_EQ(ret, DM_OK); } -HWTEST_F(DmAuthManagerTest, GetBindLevel_001, testing::ext::TestSize.Level1) -{ - int32_t bindLevel = INVALIED_TYPE; - std::string udid; - authManager_->HandleDeviceNotTrust(udid); - udid = "988989"; - authManager_->HandleDeviceNotTrust(udid); - int32_t sessionId = 32166; - authManager_->ProcIncompatible(sessionId); - - authManager_->authResponseContext_->authType == AUTH_TYPE_IMPORT_AUTH_CODE; - authManager_->authResponseContext_->importAuthCode = "importAuthCode"; - authManager_->importAuthCode_ = "importAuthCode"; - authManager_->ProcessAuthRequest(sessionId); - - authManager_->authResponseContext_->authType == AUTH_TYPE_NFC; - authManager_->authResponseContext_->isOnline = false; - authManager_->authResponseContext_->reply = 0; - authManager_->authResponseContext_->isIdenticalAccount = false; - authManager_->authResponseContext_->isAuthCodeReady = true; - authManager_->ProcessAuthRequest(sessionId); - - authManager_->authResponseContext_->reply = ERR_DM_UNSUPPORTED_AUTH_TYPE; - authManager_->authResponseContext_->authType = AUTH_TYPE_IMPORT_AUTH_CODE; - authManager_->authResponseContext_->isAuthCodeReady == false; - authManager_->ProcessAuthRequest(sessionId); -} - HWTEST_F(DmAuthManagerTest, IsAuthFinish_001, testing::ext::TestSize.Level1) { authManager_->authResponseContext_->reply = ERR_DM_UNSUPPORTED_AUTH_TYPE; -- Gitee From b9905e4d58d57029e5de30fa608daed7b5ae6ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:25:58 +0000 Subject: [PATCH 09/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 42aac4ed7..1e6a7b8b0 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -2972,7 +2972,7 @@ bool DeviceManagerImpl::CheckSinkIsSameAccount(const DmAccessCaller &caller, con } bool DeviceManagerImpl::CheckAclByIpcCode(const DmAccessCaller &caller, const DmAccessCallee &callee, - const DMIpcCmdInterfaceCode &ipcCode) + const DMIpcCmdInterfaceCode &ipcCode) { LOGI("start, ipcCode %{public}d.", static_cast(ipcCode)); std::shared_ptr req = std::make_shared(); -- Gitee From f296311c96419c63c07a6f3e2902b1ec7c2ce134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:31:27 +0000 Subject: [PATCH 10/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= 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, 1 insertion(+), 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 c2471bb76..d189ad1ae 100644 --- a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp +++ b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/dm_softbus_listener_fuzzer.cpp @@ -33,7 +33,7 @@ void DmSoftbusListenerFuzzTestNext(FuzzedDataProvider &fdp) { SoftbusListener listener; std::string networkIdStr = fdp.ConsumeRandomLengthString(); - if (!networkIdStr.empty()) { + if (!networkIdStr.empty()) { int32_t networkType = fdp.ConsumeIntegral(); listener.GetNetworkTypeByNetworkId(networkIdStr.c_str(), networkType); } -- Gitee From ff079fa7e7a897f19e6254aa184a0743c87b0ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 08:52:06 +0000 Subject: [PATCH 11/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../UTTest_dm_deviceprofile_connector_second.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp b/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp index de578f338..163e85156 100644 --- a/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp +++ b/test/commonunittest/UTTest_dm_deviceprofile_connector_second.cpp @@ -1689,8 +1689,9 @@ HWTEST_F(DeviceProfileConnectorSecondTest, GetDeviceIdAndUdidListByTokenId_002, std::vector emptyUserIds; std::string localUdid = "localDeviceId"; int32_t tokenId = 1234; - - auto result = DeviceProfileConnector::GetInstance().GetDeviceIdAndUdidListByTokenId(emptyUserIds, localUdid, tokenId); + + auto result = DeviceProfileConnector::GetInstance() + .GetDeviceIdAndUdidListByTokenId(emptyUserIds, localUdid, tokenId); EXPECT_TRUE(result.empty()); } -- Gitee From fddc8964ea0811adcbd5877757948995621dd9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:00:53 +0000 Subject: [PATCH 12/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_device_manager_service_impl_first.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unittest/UTTest_device_manager_service_impl_first.cpp b/test/unittest/UTTest_device_manager_service_impl_first.cpp index 3badcf299..ca79359a2 100644 --- a/test/unittest/UTTest_device_manager_service_impl_first.cpp +++ b/test/unittest/UTTest_device_manager_service_impl_first.cpp @@ -720,7 +720,8 @@ HWTEST_F(DeviceManagerServiceImplFirstTest, ProcessUnBindApp_003, testing::ext:: std::string extra = R"({"peerTokenId": 5678})"; std::string udid = "remoteUdid"; - EXPECT_CALL(*deviceManagerServiceImplMock_, HandleAppUnBindEvent(userId, udid, accessTokenId, peerTokenId)).Times(1); + EXPECT_CALL(*deviceManagerServiceImplMock_, + HandleAppUnBindEvent(userId, udid, accessTokenId, peerTokenId)).Times(1); deviceManagerServiceImpl_->ProcessUnBindApp(userId, accessTokenId, extra, udid); } -- Gitee From 0c9ea346ba8d9d0564c9e749db8d3302d4922fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:03:55 +0000 Subject: [PATCH 13/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_device_manager_service_two.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/unittest/UTTest_device_manager_service_two.cpp b/test/unittest/UTTest_device_manager_service_two.cpp index 178290401..2d8b82bf1 100644 --- a/test/unittest/UTTest_device_manager_service_two.cpp +++ b/test/unittest/UTTest_device_manager_service_two.cpp @@ -1818,11 +1818,6 @@ HWTEST_F(DeviceManagerServiceTest, SendShareTypeUnBindBroadCast_001, testing::ex EXPECT_NE(DeviceManagerService::GetInstance().softbusListener_, nullptr); } -HWTEST_F(DeviceManagerServiceTest, HandleCredentialDeleted_001, testing::ext::TestSize.Level1) -{ - DeviceManagerService::GetInstance().HandleCredentialDeleted("credId", "credInfo"); -} - HWTEST_F(DeviceManagerServiceTest, HandleCredentialDeleted_002, testing::ext::TestSize.Level1) { EXPECT_CALL(*deviceManagerServiceImplMock_, HandleCredentialDeleted(_, _, _, _)).Times(0); -- Gitee From 21f0e336044a9977e99e430a7dd781ac57846ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:12:55 +0000 Subject: [PATCH 14/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../inner_kits/native_cpp/src/notify/device_manager_notify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 278ebade4..0639394b1 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -419,7 +419,7 @@ void DeviceManagerNotify::OnDeviceChanged(const std::string &pkgName, const DmDe auto iter = deviceStateCallback_.find(pkgName); if (iter == deviceStateCallback_.end()) { if (deviceStatusCallback_.find(pkgName) == deviceStatusCallback_.end()) { - LOGE("error, device state callback not register, pkgName:%{public}s",pkgName.c_str()); + LOGE("error, device state callback not register, pkgName:%{public}s", pkgName.c_str()); } return; } -- Gitee From 3644582f36e0fac02b79a842fb46a772db7bdc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:14:04 +0000 Subject: [PATCH 15/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_relationship_sync_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/UTTest_relationship_sync_mgr.cpp b/test/unittest/UTTest_relationship_sync_mgr.cpp index 398e4ef07..9f6627fc7 100644 --- a/test/unittest/UTTest_relationship_sync_mgr.cpp +++ b/test/unittest/UTTest_relationship_sync_mgr.cpp @@ -811,7 +811,7 @@ HWTEST_F(ReleationShipSyncMgrTest, ToString_ValidData, testing::ext::TestSize.Le "{ isNewEvent: false, userId: 12345, accountId: a******3, tokenId: 67890, " + "peerUdids: [ u******1, u******2 ], peerUdid: p******d, " + "accountName: t******t, syncUserIdFlag: 1, " + - "userIds: [ { 1, userId: 111 }, { 0, userId: 222 } ], broadCastId: 0 }"; + "userIds: [ { 1, userId: 111 }, { 0, userId: 222 } ], broadCastId: 0 }"; EXPECT_EQ(msg.ToString(), expected); } -- Gitee From 4c9ed1c1429bcd6fd0908183f49ef8ec0bbf4d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:18:32 +0000 Subject: [PATCH 16/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../UTTest_device_manager_service_three.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/unittest/UTTest_device_manager_service_three.cpp b/test/unittest/UTTest_device_manager_service_three.cpp index f944566c4..fc815051a 100644 --- a/test/unittest/UTTest_device_manager_service_three.cpp +++ b/test/unittest/UTTest_device_manager_service_three.cpp @@ -725,7 +725,6 @@ HWTEST_F(DeviceManagerServiceThreeTest, SubscribePackageCommonEvent_301, testing DeviceManagerService::GetInstance().softbusListener_ = std::make_shared(); EXPECT_NE(DeviceManagerService::GetInstance().softbusListener_, nullptr); DeviceManagerService::GetInstance().softbusListener_ = nullptr; - } HWTEST_F(DeviceManagerServiceThreeTest, SubscribePackageCommonEvent_302, testing::ext::TestSize.Level1) @@ -816,18 +815,18 @@ HWTEST_F(DeviceManagerServiceThreeTest, NotifyRemoteUnBindAppByWifi_001, testing HWTEST_F(DeviceManagerServiceThreeTest, ProcessReceiveRspAppUninstall_301, testing::ext::TestSize.Level1) { - std::string remoteUdid = "ohos"; - DeviceManagerService::GetInstance().timer_ = std::make_shared(); - DeviceManagerService::GetInstance().ProcessReceiveRspAppUninstall(remoteUdid); - EXPECT_NE(DeviceManagerService::GetInstance().timer_, nullptr); + std::string remoteUdid = "ohos"; + DeviceManagerService::GetInstance().timer_ = std::make_shared(); + DeviceManagerService::GetInstance().ProcessReceiveRspAppUninstall(remoteUdid); + EXPECT_NE(DeviceManagerService::GetInstance().timer_, nullptr); } HWTEST_F(DeviceManagerServiceThreeTest, ProcessReceiveRspAppUninstall_302, testing::ext::TestSize.Level1) { - std::string remoteUdid = "ohos"; - DeviceManagerService::GetInstance().timer_ = nullptr; - DeviceManagerService::GetInstance().ProcessReceiveRspAppUninstall(remoteUdid); - EXPECT_EQ(DeviceManagerService::GetInstance().timer_, nullptr); + std::string remoteUdid = "ohos"; + DeviceManagerService::GetInstance().timer_ = nullptr; + DeviceManagerService::GetInstance().ProcessReceiveRspAppUninstall(remoteUdid); + EXPECT_EQ(DeviceManagerService::GetInstance().timer_, nullptr); } HWTEST_F(DeviceManagerServiceThreeTest, ProcessReceiveRspAppUnbind_301, testing::ext::TestSize.Level1) -- Gitee From 32f6eed49ec89d45a188302c68fe14fc48f2bdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:20:27 +0000 Subject: [PATCH 17/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_device_manager_service_two.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/UTTest_device_manager_service_two.cpp b/test/unittest/UTTest_device_manager_service_two.cpp index 2d8b82bf1..867043eff 100644 --- a/test/unittest/UTTest_device_manager_service_two.cpp +++ b/test/unittest/UTTest_device_manager_service_two.cpp @@ -1942,6 +1942,7 @@ HWTEST_F(DeviceManagerServiceTest, GetNotifyRemoteUnBindAppWay_001, testing::ext EXPECT_NE(DeviceManagerService::GetInstance().softbusListener_, nullptr); DeviceManagerService::GetInstance().softbusListener_ = nullptr; } + HWTEST_F(DeviceManagerServiceTest, GetNotifyRemoteUnBindAppWay_002, testing::ext::TestSize.Level1) { int32_t userId = 1001; @@ -1951,7 +1952,6 @@ HWTEST_F(DeviceManagerServiceTest, GetNotifyRemoteUnBindAppWay_002, testing::ext DeviceManagerService::GetInstance().softbusListener_ = nullptr; DeviceManagerService::GetInstance().GetNotifyRemoteUnBindAppWay(userId, tokenId, wifiDevices, isBleWay); EXPECT_EQ(DeviceManagerService::GetInstance().softbusListener_, nullptr); - } } // namespace } // namespace DistributedHardware -- Gitee From b2790e4c4724392c8786d7b55ce705ae8c420eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:21:59 +0000 Subject: [PATCH 18/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- .../dmcommtooltwo_fuzzer/dm_comm_tool_two_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/servicesfuzztest/dmcommtooltwo_fuzzer/dm_comm_tool_two_fuzzer.cpp b/test/servicesfuzztest/dmcommtooltwo_fuzzer/dm_comm_tool_two_fuzzer.cpp index 18652864e..a797643db 100644 --- a/test/servicesfuzztest/dmcommtooltwo_fuzzer/dm_comm_tool_two_fuzzer.cpp +++ b/test/servicesfuzztest/dmcommtooltwo_fuzzer/dm_comm_tool_two_fuzzer.cpp @@ -36,7 +36,7 @@ void GenerateUserIds(FuzzedDataProvider& fdp, std::vector& outIds) auto count = fdp.ConsumeIntegralInRange(0, 10); - while(count-- > 0 && fdp.remaining_bytes() >= sizeof(uint32_t)) { + while (count-- > 0 && fdp.remaining_bytes() >= sizeof(uint32_t)) { outIds.push_back(fdp.ConsumeIntegral()); } } -- Gitee From 66d1fd0edadbbaa6e596681d921d48d0ae10fb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:23:26 +0000 Subject: [PATCH 19/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- services/service/src/device_manager_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 2bcd88c8f..3c3238769 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -1925,7 +1925,7 @@ bool DeviceManagerService::CheckAccessControl(const DmAccessCaller &caller, cons LOGE("GetAccessUdidByNetworkId failed."); return false; } - return dmServiceImpl_->CheckAccessControl(caller, srcUdid, callee, sinkUdid); + return dmServiceImpl_->CheckAccessControl(caller, srcUdid, callee, sinkUdid); } bool DeviceManagerService::CheckIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee) -- Gitee From e7d2ade1aabcd419dc83b7f10c99902281096fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:24:39 +0000 Subject: [PATCH 20/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_device_manager_service_two.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/unittest/UTTest_device_manager_service_two.cpp b/test/unittest/UTTest_device_manager_service_two.cpp index 867043eff..d6298c7b8 100644 --- a/test/unittest/UTTest_device_manager_service_two.cpp +++ b/test/unittest/UTTest_device_manager_service_two.cpp @@ -1825,11 +1825,6 @@ HWTEST_F(DeviceManagerServiceTest, HandleCredentialDeleted_002, testing::ext::Te DeviceManagerService::GetInstance().HandleCredentialDeleted(nullptr, "credInfo"); } -HWTEST_F(DeviceManagerServiceTest, HandleCredentialDeleted_003, testing::ext::TestSize.Level1) -{ - DeviceManagerService::GetInstance().HandleCredentialDeleted("credId", nullptr); -} - HWTEST_F(DeviceManagerServiceTest, HandleCredentialDeleted_004, testing::ext::TestSize.Level1) { EXPECT_CALL(*multipleUserConnectorMock_, GetCurrentAccountUserID()).Times(0); -- Gitee From 83be3f3fe023d6a2201239e92195c89969d574d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:38:56 +0000 Subject: [PATCH 21/24] update interfaces/kits/ndk/include/oh_device_manager_err_code.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- interfaces/kits/ndk/include/oh_device_manager_err_code.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/ndk/include/oh_device_manager_err_code.h b/interfaces/kits/ndk/include/oh_device_manager_err_code.h index 0cf3c61d6..cd33a88fe 100644 --- a/interfaces/kits/ndk/include/oh_device_manager_err_code.h +++ b/interfaces/kits/ndk/include/oh_device_manager_err_code.h @@ -47,7 +47,7 @@ extern "C" { * * @since 20 */ -typedef enum DeviceManagerErrorCode { +typedef enum DeviceManager_ErrorCode { /** * @error The operation is successful. */ @@ -72,7 +72,7 @@ typedef enum DeviceManagerErrorCode { * @error Failed to obtain the bundleName. */ DM_ERR_OBTAIN_BUNDLE_NAME = 11600109, -} DeviceManagerErrorCode; +} DeviceManager_ErrorCode; #ifdef __cplusplus }; #endif -- Gitee From d4cc452be9aaa66c9a7dfc373459dd826842e731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:39:24 +0000 Subject: [PATCH 22/24] update interfaces/kits/ndk/include/oh_device_manager.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- interfaces/kits/ndk/include/oh_device_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/ndk/include/oh_device_manager.h b/interfaces/kits/ndk/include/oh_device_manager.h index a3b262ec0..e4218188e 100644 --- a/interfaces/kits/ndk/include/oh_device_manager.h +++ b/interfaces/kits/ndk/include/oh_device_manager.h @@ -49,7 +49,7 @@ extern "C" { * @param localDeviceName This is an output parameter. It indicates the address pointer of the localDeviceName. * You need to manually release space resources after using. * @param len This is an output parameter. Length of the localDeviceName. - * @return Returns the status code of the execution. For detail, see {@link DeviceManagerErrorCode}. + * @return Returns the status code of the execution. For detail, see {@link DeviceManager_ErrorCode}. * Returns {@link ERR_OK}, The operation is successful. * Returns {@link DM_ERR_FAILED}, Failed to execute the function. * Returns {@link DM_ERR_OBTAIN_SERVICE}, Failed to obtain devicemanager service. -- Gitee From 8205ce29fa3c8770b168e45da19a2a4c51974303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 11:42:59 +0000 Subject: [PATCH 23/24] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- test/unittest/UTTest_device_manager_service_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/UTTest_device_manager_service_impl.cpp b/test/unittest/UTTest_device_manager_service_impl.cpp index c2c5a453e..25babd3e1 100644 --- a/test/unittest/UTTest_device_manager_service_impl.cpp +++ b/test/unittest/UTTest_device_manager_service_impl.cpp @@ -35,7 +35,7 @@ void DeviceManagerServiceImplTest::SetUp() uint64_t tokenId = IPCSkeleton::GetCallingTokenID(); deviceManagerServiceImpl_->InitAndRegisterAuthMgr(true, tokenId, session, 0, "com.test"); } -const std::string testID("111111"); +const std::string TEST_ID("111111"); void DeviceManagerServiceImplTest::TearDown() { -- Gitee From f35c90cdec1da56d5b986485de93c7eaa25085d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E6=99=96?= Date: Thu, 12 Jun 2025 12:06:26 +0000 Subject: [PATCH 24/24] update services/implementation/src/attest/dm_auth_attest_common.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王宇晖 --- services/implementation/src/attest/dm_auth_attest_common.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/services/implementation/src/attest/dm_auth_attest_common.cpp b/services/implementation/src/attest/dm_auth_attest_common.cpp index 5765e816c..deec44d10 100644 --- a/services/implementation/src/attest/dm_auth_attest_common.cpp +++ b/services/implementation/src/attest/dm_auth_attest_common.cpp @@ -120,10 +120,6 @@ bool AuthAttestCommon::DeserializeDmCertChain(const std::string &data, DmCertCha JsonObject jsonObject; jsonObject.Parse(data); const uint32_t certCount = jsonObject[TAG_CERT_COUNT].Get(); - if (certCount > MAX_CERT_COUNT) { - LOGE("Invalid certCount too large"); - return false; - } JsonObject jsonArrayObj(JsonCreateType::JSON_CREATE_TYPE_ARRAY); jsonArrayObj.Parse(jsonObject[TAG_CERT].Dump()); DmBlob *certs = new DmBlob[certCount]; -- Gitee