diff --git a/services/implementation/src/authentication_v2/dm_freeze_process.cpp b/services/implementation/src/authentication_v2/dm_freeze_process.cpp index 9e7d4a1e3bb90ed0fffebe5a7364418026474a8a..7fbd667c0a2911e939f9eed6e7acc8a4502cbed5 100644 --- a/services/implementation/src/authentication_v2/dm_freeze_process.cpp +++ b/services/implementation/src/authentication_v2/dm_freeze_process.cpp @@ -42,6 +42,7 @@ constexpr int64_t MAX_FREEZE_DURATION_SEC = 10 * 60; DM_IMPLEMENT_SINGLE_INSTANCE(FreezeProcess); +//LCOV_EXCL_START int32_t FreezeProcess::SyncFreezeData() { LOGI("called"); @@ -78,6 +79,7 @@ int32_t FreezeProcess::SyncFreezeData() LOGI("Sync freeze data success"); return DM_OK; } +//LCOV_EXCL_STOP int32_t FreezeProcess::ConvertJsonToDeviceFreezeState(const std::string &result, DeviceFreezeState &freezeStateObj) { @@ -169,6 +171,7 @@ int32_t FreezeProcess::CleanFreezeRecord(int64_t nowTime) return DM_OK; } +//LCOV_EXCL_START int32_t FreezeProcess::CleanBindFailedEvents(int64_t reservedDataTimeStamp) { std::lock_guard lock(bindFailedEventsCacheMtx_); @@ -204,6 +207,7 @@ int32_t FreezeProcess::CleanBindFailedEvents(int64_t reservedDataTimeStamp) LOGI("CleanBindFailedEvents success"); return DM_OK; } +//LCOV_EXCL_STOP int32_t FreezeProcess::CleanFreezeState(int64_t reservedDataTimeStamp) { @@ -241,6 +245,7 @@ void FreezeProcess::ConvertDeviceFreezeStateToJson(const DeviceFreezeState &valu result = jsonObj.Dump(); } +//LCOV_EXCL_START int32_t FreezeProcess::DeleteFreezeRecord() { if (KVAdapterManager::GetInstance().DeleteFreezeData(FREEZE_STATE_KEY) != DM_OK) { @@ -295,6 +300,7 @@ int32_t FreezeProcess::UpdateFreezeRecord() bindFailedEventsCache_ = bindFailedEventsTmp; return UpdateFreezeState(nowTime); } +//LCOV_EXCL_STOP int32_t FreezeProcess::UpdateFreezeState(int64_t nowTime) { diff --git a/services/implementation/src/dependency/hichain/hichain_connector.cpp b/services/implementation/src/dependency/hichain/hichain_connector.cpp index 6b3fda504deb3002e48e2b7c6cfad164d6b3540e..fa3d0aef602c996a5f90243f5c123273c985a92e 100644 --- a/services/implementation/src/dependency/hichain/hichain_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_connector.cpp @@ -899,6 +899,7 @@ int32_t HiChainConnector::GetGroupId(const std::string &userId, const int32_t gr return ERR_DM_FAILED; } +//LCOV_EXCL_START int32_t HiChainConnector::ParseRemoteCredential(const int32_t groupType, const std::string &userId, const JsonObject &jsonDeviceList, std::string ¶ms, int32_t &osAccountUserId) { @@ -926,6 +927,7 @@ int32_t HiChainConnector::ParseRemoteCredential(const int32_t groupType, const s } return DM_OK; } +//LCOV_EXCL_STOP int32_t HiChainConnector::addMultiMembers(const int32_t groupType, const std::string &userId, const JsonObject &jsonDeviceList) diff --git a/services/implementation/src/dependency/softbus/softbus_connector.cpp b/services/implementation/src/dependency/softbus/softbus_connector.cpp index 90606a916a10fd09fe3239f4c3b031ef976a5b52..ece9d9fe5bf7b91c130ac289897b89ff3a63f4ca 100644 --- a/services/implementation/src/dependency/softbus/softbus_connector.cpp +++ b/services/implementation/src/dependency/softbus/softbus_connector.cpp @@ -187,6 +187,7 @@ std::string SoftbusConnector::MatchTargetVersion(const std::string &localVersion } #endif +//LCOV_EXCL_START int32_t SoftbusConnector::SyncLocalAclListProcess(const DevUserInfo &localDevUserInfo, const DevUserInfo &remoteDevUserInfo, std::string remoteAclList) { @@ -235,6 +236,7 @@ int32_t SoftbusConnector::SyncLocalAclListProcess(const DevUserInfo &localDevUse return DM_OK; #endif } +//LCOV_EXCL_STOP int32_t SoftbusConnector::GetAclListHash(const DevUserInfo &localDevUserInfo, const DevUserInfo &remoteDevUserInfo, std::string &aclList) @@ -742,6 +744,7 @@ void SoftbusConnector::DeleteOffLineTimer(std::string &udidHash) } } +//LCOV_EXCL_START bool SoftbusConnector::CheckIsNeedJoinLnn(const std::string &udid, const std::string &deviceId) { if (udid.empty() || deviceId.empty()) { @@ -790,6 +793,7 @@ bool SoftbusConnector::CheckIsNeedJoinLnn(const std::string &udid, const std::st } return true; } +//LCOV_EXCL_STOP // isHash:传入的deviceId是否为哈希值 bool SoftbusConnector::CheckIsOnline(const std::string &targetDeviceIdHash, bool isHash) diff --git a/services/service/src/relationshipsyncmgr/dm_comm_tool.cpp b/services/service/src/relationshipsyncmgr/dm_comm_tool.cpp index 088d4e61c69e6213baedd49124667ae1330eb314..50528018fa485c7e316ce638aa135f7aaea65e0d 100644 --- a/services/service/src/relationshipsyncmgr/dm_comm_tool.cpp +++ b/services/service/src/relationshipsyncmgr/dm_comm_tool.cpp @@ -391,6 +391,7 @@ void DMCommTool::DMCommToolEventHandler::HandleLocalUserIdEvent(const std::share } } +//LCOV_EXCL_START void DMCommTool::ProcessReceiveCommonEvent(const std::shared_ptr commMsg) { LOGI("start"); @@ -509,6 +510,7 @@ void DMCommTool::ProcessReceiveUserIdsEvent(const std::shared_ptr userIdsMsg.backgroundUserIds, rmtUdid); } } +//LCOV_EXCL_STOP void DMCommTool::ProcessReceiveUninstAppEvent(const std::shared_ptr commMsg) { @@ -783,6 +785,7 @@ void DMCommTool::RspUserStop(const std::string rmtNetworkId, int32_t socketId, i LOGI("success"); } +//LCOV_EXCL_START void DMCommTool::ProcessResponseUserStopEvent(const std::shared_ptr commMsg) { LOGI("start"); @@ -807,6 +810,7 @@ void DMCommTool::ProcessResponseUserStopEvent(const std::shared_ptr(localDeviceId); DeviceManagerService::GetInstance().HandleUserStop(stopUserId, localUdid, acceptEventUdids); } +//LCOV_EXCL_STOP int32_t DMCommTool::SendLogoutAccountInfo(const std::string &rmtNetworkId, const std::string &accountId, int32_t userId) @@ -850,6 +854,7 @@ int32_t DMCommTool::SendLogoutAccountInfo(const std::string &rmtNetworkId, return DM_OK; } +//LCOV_EXCL_START void DMCommTool::ProcessReceiveLogoutEvent(const std::shared_ptr commMsg) { CHECK_NULL_VOID(commMsg); @@ -883,6 +888,7 @@ void DMCommTool::ProcessReceiveLogoutEvent(const std::shared_ptr c rmtUdid, logoutAccountMsg.userId); LOGI("success."); } +//LCOV_EXCL_STOP int32_t DMCommTool::StartCommonEvent(std::string commonEventType, EventCallback eventCallback) { diff --git a/services/service/src/relationshipsyncmgr/dm_transport.cpp b/services/service/src/relationshipsyncmgr/dm_transport.cpp index 4ddf272a6eb686f94f89cbb59dcf1e6792a60ac5..0254ede7511cb2550e54287695c8d69ba311616b 100644 --- a/services/service/src/relationshipsyncmgr/dm_transport.cpp +++ b/services/service/src/relationshipsyncmgr/dm_transport.cpp @@ -195,6 +195,7 @@ void OnBytes(int32_t socket, const void *data, uint32_t dataLen) dmCommToolSPtr->GetDMTransportPtr()->OnBytesReceived(socket, data, dataLen); } +//LCOV_EXCL_START void OnMessage(int32_t socket, const void *data, uint32_t dataLen) { (void)socket; @@ -218,6 +219,7 @@ void OnFile(int32_t socket, FileEvent *event) (void)event; LOGI("socket: %{public}d", socket); } +//LCOV_EXCL_STOP void OnQos(int32_t socket, QoSEvent eventId, const QosTV *qos, uint32_t qosCount) { @@ -242,6 +244,7 @@ ISocketListener iSocketListener = { .OnQos = OnQos }; +//LCOV_EXCL_START int32_t DMTransport::CreateServerSocket() { LOGI("CreateServerSocket start"); @@ -257,6 +260,7 @@ int32_t DMTransport::CreateServerSocket() LOGI("CreateServerSocket Finish, socket: %{public}d", socket); return socket; } +//LCOV_EXCL_STOP int32_t DMTransport::CreateClientSocket(const std::string &rmtNetworkId) { @@ -279,6 +283,7 @@ int32_t DMTransport::CreateClientSocket(const std::string &rmtNetworkId) return socket; } +//LCOV_EXCL_START int32_t DMTransport::Init() { LOGI("Init DMTransport"); @@ -328,6 +333,7 @@ int32_t DMTransport::UnInit() } return DM_OK; } +//LCOV_EXCL_STOP bool DMTransport::IsDeviceSessionOpened(const std::string &rmtNetworkId, int32_t &socketId) { diff --git a/services/service/src/relationshipsyncmgr/dm_transport_msg.cpp b/services/service/src/relationshipsyncmgr/dm_transport_msg.cpp index 2a0abcdc10e5dff055390734a3951f3750ed101a..5070b23d83d259845b15555f2f44676b491bba60 100644 --- a/services/service/src/relationshipsyncmgr/dm_transport_msg.cpp +++ b/services/service/src/relationshipsyncmgr/dm_transport_msg.cpp @@ -258,6 +258,7 @@ void ToJson(cJSON *jsonObject, const LogoutAccountMsg &accountInfo) cJSON_AddNumberToObject(jsonObject, DSOFTBUS_NOTIFY_USERID_KEY, accountInfo.userId); } +//LCOV_EXCL_START void FromJson(const cJSON *jsonObject, LogoutAccountMsg &accountInfo) { if (jsonObject == nullptr) { @@ -274,6 +275,7 @@ void FromJson(const cJSON *jsonObject, LogoutAccountMsg &accountInfo) accountInfo.userId = userIdObj->valueint; } } +//LCOV_EXCL_STOP void ToJson(cJSON *jsonObject, const UninstAppMsg &uninstAppMsg) { @@ -286,6 +288,7 @@ void ToJson(cJSON *jsonObject, const UninstAppMsg &uninstAppMsg) cJSON_AddNumberToObject(jsonObject, DSOFTBUS_NOTIFY_TOKENID_KEY, uninstAppMsg.tokenId_); } +//LCOV_EXCL_START void FromJson(const cJSON *jsonObject, UninstAppMsg &uninstAppMsg) { if (jsonObject == nullptr) { @@ -306,6 +309,7 @@ void FromJson(const cJSON *jsonObject, UninstAppMsg &uninstAppMsg) uninstAppMsg.tokenId_ = tokenIdObj->valueint; } } +//LCOV_EXCL_STOP void ToJson(cJSON *jsonObject, const UnBindAppMsg &unBindAppMsg) { diff --git a/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp b/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp index dcc417f83afeac898a424a45cedbfd5167105c30..b76acc33684e1144f3b95b58bf837f5107649f74 100644 --- a/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp +++ b/test/commonfuzztest/hichainconnector_fuzzer/hichain_connector_fuzzer.cpp @@ -421,6 +421,33 @@ void GetGroupInfoExtFuzzTest(const uint8_t* data, size_t size) std::shared_ptr hichainConnector = std::make_shared(); hichainConnector->GetGroupInfoExt(userId, queryParams, groupList); } + +void DeleteHoDeviceFuzzTest(const uint8_t* data, size_t size) +{ + size_t count = 2; + if (data == nullptr || size < sizeof(size_t) * count + sizeof(int32_t) * count) { + return; + } + FuzzedDataProvider fdp(data, size); + + size_t maxLength = 64; + size_t minCount = 1; + size_t maxCount = 10; + std::string peerUdid = fdp.ConsumeRandomLengthString(maxLength); + size_t foreGroundUserCount = fdp.ConsumeIntegralInRange(minCount, maxCount); + std::vector foreGroundUserIds; + for (size_t i = 0; i < foreGroundUserCount; ++i) { + foreGroundUserIds.push_back(fdp.ConsumeIntegral()); + } + + size_t backGroundUserCount = fdp.ConsumeIntegralInRange(minCount, maxCount); + std::vector backGroundUserIds; + for (size_t i = 0; i < backGroundUserCount; ++i) { + backGroundUserIds.push_back(fdp.ConsumeIntegral()); + } + std::shared_ptr hichainConnector = std::make_shared(); + hichainConnector->DeleteHoDevice(peerUdid, foreGroundUserIds, backGroundUserIds); +} } } @@ -436,5 +463,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::DistributedHardware::HiChainConnectorSixthFuzzTest(data, size); OHOS::DistributedHardware::HiChainConnectorSevenhFuzzTest(data, size); OHOS::DistributedHardware::GetGroupInfoExtFuzzTest(data, size); + OHOS::DistributedHardware::DeleteHoDeviceFuzzTest(data, size); return 0; } \ No newline at end of file