From bda23fe38ce1594b5e5aac2892fa8726aebcc719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Thu, 21 Aug 2025 14:59:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=A3=80=E8=A7=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication/dm_auth_manager.cpp | 8 ++------ .../auth_stages/auth_confirm.cpp | 12 ++++++++---- .../auth_stages/auth_negotiate.cpp | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 307ee014f..ddcf91253 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2853,12 +2853,8 @@ void DmAuthManager::PutAccessControlList() Crypto::GetUdidHash(localUdid, reinterpret_cast(mUdidHash)); std::string localUdidHash = static_cast(mUdidHash); DmAclInfo aclInfo; - aclInfo.bindType = DM_ACROSS_ACCOUNT; - if (authResponseContext_->localAccountId == "ohosAnonymousUid" || - authResponseContext_->remoteAccountId == "ohosAnonymousUid") { - aclInfo.bindType = DM_POINT_TO_POINT; - authForm_ = DmAuthForm::PEER_TO_PEER; - } + aclInfo.bindType = DM_POINT_TO_POINT; + authForm_ = DmAuthForm::PEER_TO_PEER; aclInfo.bindLevel = authResponseContext_->bindLevel; aclInfo.trustDeviceId = remoteDeviceId_; aclInfo.authenticationType = ALLOW_AUTH_ONCE; diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp index c5fe661fd..2e8a3b580 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_confirm.cpp @@ -197,8 +197,10 @@ void AuthSrcConfirmState::GetSrcCredType(std::shared_ptr context, CHECK_NULL_VOID(context); std::vector deleteCredInfo; for (const auto &item : credInfo.Items()) { - if (!item.Contains(FILED_CRED_TYPE) || !item[FILED_CRED_TYPE].IsNumberInteger() || - !item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + if (!item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + continue; + } + if (!item.Contains(FILED_CRED_TYPE) || !item[FILED_CRED_TYPE].IsNumberInteger()) { deleteCredInfo.push_back(item[FILED_CRED_ID].Get()); DirectlyDeleteCredential(context, context->accesser.userId, item); continue; @@ -553,10 +555,12 @@ void AuthSrcConfirmState::GetSrcCredentialInfo(std::shared_ptr co } std::vector deleteCredInfo; for (auto &item : credInfo.Items()) { // id1:json1, id2:json2, id3:json3 + if (!item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + continue; + } uint32_t credType = DmAuthState::GetCredentialType(context, item); if (credType == DM_INVALIED_TYPE || !item.Contains(FILED_CRED_TYPE) || - !item[FILED_CRED_TYPE].IsNumberInteger() || !item.Contains(FILED_CRED_ID) || - !item[FILED_CRED_ID].IsString()) { + !item[FILED_CRED_TYPE].IsNumberInteger()) { deleteCredInfo.push_back(item[FILED_CRED_ID].Get()); continue; } diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp index 853d616dc..b9168383a 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp @@ -303,8 +303,10 @@ void AuthSinkNegotiateStateMachine::GetSinkCredType(std::shared_ptr deleteCredInfo; for (const auto &item : credInfo.Items()) { - if (!item.Contains(FILED_CRED_TYPE) || !item[FILED_CRED_TYPE].IsNumberInteger() || - !item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + if (!item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + continue; + } + if (!item.Contains(FILED_CRED_TYPE) || !item[FILED_CRED_TYPE].IsNumberInteger()) { deleteCredInfo.push_back(item[FILED_CRED_ID].Get()); DirectlyDeleteCredential(context, context->accessee.userId, item); continue; @@ -378,8 +380,10 @@ void AuthSinkNegotiateStateMachine::GetSinkProxyCredTypeForP2P(std::shared_ptrproxyAccessee.credInfoJson); } for (const auto &credItem : credInfoJson.Items()) { - if (!credItem.Contains(FILED_CRED_TYPE) || !credItem[FILED_CRED_TYPE].IsNumberInteger() || - !credItem.Contains(FILED_CRED_ID) || !credItem[FILED_CRED_ID].IsString()) { + if (!credItem.Contains(FILED_CRED_ID) || !credItem[FILED_CRED_ID].IsString()) { + continue; + } + if (!credItem.Contains(FILED_CRED_TYPE) || !credItem[FILED_CRED_TYPE].IsNumberInteger()) { deleteCredInfo.push_back(credItem[FILED_CRED_ID].Get()); DirectlyDeleteCredential(context, context->accessee.userId, credItem); continue; @@ -661,10 +665,12 @@ void AuthSinkNegotiateStateMachine::GetSinkCredentialInfo(std::shared_ptr deleteCredInfo; for (auto& item : credInfo.Items()) { // id1:json1, id2:json2, id3:json3 + if (!item.Contains(FILED_CRED_ID) || !item[FILED_CRED_ID].IsString()) { + continue; + } uint32_t credType = DmAuthState::GetCredentialType(context, item); if (credType == DM_INVALIED_TYPE || !item.Contains(FILED_CRED_TYPE) || - !item[FILED_CRED_TYPE].IsNumberInteger() || !item.Contains(FILED_CRED_ID) || - !item[FILED_CRED_ID].IsString()) { + !item[FILED_CRED_TYPE].IsNumberInteger() || ) { deleteCredInfo.push_back(item[FILED_CRED_ID].Get()); continue; } -- Gitee From d2a667277ba4071c40d4d06034d1c9b50a627f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Thu, 21 Aug 2025 17:46:30 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=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/authentication/dm_auth_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index ddcf91253..ca76965b8 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2361,6 +2361,7 @@ void DmAuthManager::ResponseCredential() bool DmAuthManager::AuthDeviceTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen) { LOGI("DmAuthManager::onTransmit start."); + CHECK_NULL_VOID(authResponseContext_); if (requestId != authResponseContext_->requestId) { LOGE("DmAuthManager::onTransmit requestId %{public}" PRId64"is error.", requestId); return false; -- Gitee From d043a88006670700fbb36e301c9ec8b0e050dc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Thu, 21 Aug 2025 17:59:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=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/authentication/dm_auth_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index ca76965b8..81f3e39f0 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2361,7 +2361,7 @@ void DmAuthManager::ResponseCredential() bool DmAuthManager::AuthDeviceTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen) { LOGI("DmAuthManager::onTransmit start."); - CHECK_NULL_VOID(authResponseContext_); + CHECK_NULL_RETURN(authResponseContext_, false); if (requestId != authResponseContext_->requestId) { LOGE("DmAuthManager::onTransmit requestId %{public}" PRId64"is error.", requestId); return false; -- Gitee From ed18bef753bbed05ddcaa7ef3e14f5b32d130966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Thu, 21 Aug 2025 19:14:20 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication_v2/auth_stages/auth_negotiate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp index b9168383a..c67434199 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp @@ -670,7 +670,7 @@ void AuthSinkNegotiateStateMachine::GetSinkCredentialInfo(std::shared_ptr()); continue; } -- Gitee From 244fcc3c5a0040efcde1fd532a161497f41735a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Fri, 22 Aug 2025 11:54:09 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../implementation/src/authentication/dm_auth_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 81f3e39f0..e237a3678 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -2854,8 +2854,12 @@ void DmAuthManager::PutAccessControlList() Crypto::GetUdidHash(localUdid, reinterpret_cast(mUdidHash)); std::string localUdidHash = static_cast(mUdidHash); DmAclInfo aclInfo; - aclInfo.bindType = DM_POINT_TO_POINT; - authForm_ = DmAuthForm::PEER_TO_PEER; + aclInfo.bindType = DM_ACROSS_ACCOUNT; + if (authResponseContext_->localAccountId == "ohosAnonymousUid" || + authResponseContext_->remoteAccountId == "ohosAnonymousUid") { + aclInfo.bindType = DM_POINT_TO_POINT; + authForm_ = DmAuthForm::PEER_TO_PEER; + } aclInfo.bindLevel = authResponseContext_->bindLevel; aclInfo.trustDeviceId = remoteDeviceId_; aclInfo.authenticationType = ALLOW_AUTH_ONCE; -- Gitee