From d1af55ab9948ea8e3817a6a0d2de31584a9b50ec Mon Sep 17 00:00:00 2001 From: dinghao Date: Sat, 5 Jul 2025 19:34:50 +0800 Subject: [PATCH 1/2] modify code check Signed-off-by: dinghao --- .../auth_stages/auth_credential.cpp | 2 +- .../hichain/hichain_auth_connector.cpp | 2 +- .../src/devicenamemgr/device_name_manager.cpp | 20 +++++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp index 4bada104f..816627a40 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp @@ -509,7 +509,7 @@ int32_t AuthCredentialAgreeState::AgreeCredential(DmAuthScope authorizedScope, std::string selfCredId = authContext->GetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope); std::string credId; LOGI("AuthCredentialAgreeState::AgreeCredential agree with accountId %{public}d and param %{public}s.", - osAccountId, GetAnonyJsonString(authParamsString).c_str()); + GetAnonyInt32(osAccountId), GetAnonyJsonString(authParamsString).c_str()); int32_t ret = authContext->hiChainAuthConnector->AgreeCredential(osAccountId, selfCredId, authParamsString, credId); if (ret != DM_OK) { diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index b659af1ad..ab1c4a7e9 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -501,7 +501,7 @@ int32_t HiChainAuthConnector::ImportCredential(int32_t osAccountId, int32_t peer std::string publicKey) { LOGI("start, deviceId: %{public}s, peerOsAccountId: %{public}d", - GetAnonyString(deviceId).c_str(), peerOsAccountId); + GetAnonyString(deviceId).c_str(), GetAnonyInt32(peerOsAccountId)); JsonObject jsonObj; jsonObj["osAccountId"] = osAccountId; jsonObj["peerOsAccountId"] = peerOsAccountId; diff --git a/services/service/src/devicenamemgr/device_name_manager.cpp b/services/service/src/devicenamemgr/device_name_manager.cpp index 01b689eff..f680813df 100644 --- a/services/service/src/devicenamemgr/device_name_manager.cpp +++ b/services/service/src/devicenamemgr/device_name_manager.cpp @@ -599,7 +599,7 @@ int32_t DeviceNameManager::GetValue(const std::string &tableName, int32_t userId std::string proxyUri = GetProxyUriStr(tableName, userId); auto helper = CreateDataShareHelper(proxyUri); if (helper == nullptr) { - LOGE("helper is nullptr, proxyUri=%{public}s", proxyUri.c_str()); + LOGE("helper is nullptr, proxyUri=%{public}s", GetAnonyString(proxyUri).c_str()); return ERR_DM_POINT_NULL; } std::vector columns = { SETTING_COLUMN_VALUE }; @@ -609,13 +609,15 @@ int32_t DeviceNameManager::GetValue(const std::string &tableName, int32_t userId auto resultSet = helper->Query(uri, predicates, columns); ReleaseDataShareHelper(helper); if (resultSet == nullptr) { - LOGE("Query failed key=%{public}s, proxyUri=%{public}s", key.c_str(), proxyUri.c_str()); + LOGE("Query failed key=%{public}s, proxyUri=%{public}s", key.c_str(), + GetAnonyString(proxyUri).c_str()); return ERR_DM_POINT_NULL; } int32_t count = 0; resultSet->GetRowCount(count); if (count == 0) { - LOGW("no value, key=%{public}s, proxyUri=%{public}s", key.c_str(), proxyUri.c_str()); + LOGW("no value, key=%{public}s, proxyUri=%{public}s", key.c_str(), + GetAnonyString(proxyUri).c_str()); resultSet->Close(); return DM_OK; } @@ -623,12 +625,14 @@ int32_t DeviceNameManager::GetValue(const std::string &tableName, int32_t userId resultSet->GoToRow(index); int32_t ret = resultSet->GetString(index, value); if (ret != DataShare::E_OK) { - LOGE("get value failed, ret=%{public}d, proxyUri=%{public}s", ret, proxyUri.c_str()); + LOGE("get value failed, ret=%{public}d, proxyUri=%{public}s", ret, + GetAnonyString(proxyUri).c_str()); resultSet->Close(); return ret; } resultSet->Close(); - LOGI("proxyUri=%{public}s, value=%{public}s", proxyUri.c_str(), GetAnonyString(value).c_str()); + LOGI("proxyUri=%{public}s, value=%{public}s", GetAnonyString(proxyUri).c_str(), + GetAnonyString(value).c_str()); return DM_OK; } @@ -639,7 +643,7 @@ int32_t DeviceNameManager::SetValue(const std::string &tableName, int32_t userId auto helper = CreateDataShareHelper(proxyUri); if (helper == nullptr) { LOGE("helper is nullptr, proxyUri=%{public}s, value=%{public}s", - proxyUri.c_str(), GetAnonyString(value).c_str()); + GetAnonyString(proxyUri).c_str(), GetAnonyString(value).c_str()); return ERR_DM_POINT_NULL; } DataShare::DataShareValuesBucket val; @@ -651,13 +655,13 @@ int32_t DeviceNameManager::SetValue(const std::string &tableName, int32_t userId int32_t ret = helper->Update(uri, predicates, val); if (ret <= 0) { LOGW("Update failed, ret=%{public}d, proxyUri=%{public}s, value=%{public}s", - ret, proxyUri.c_str(), GetAnonyString(value).c_str()); + ret, GetAnonyString(proxyUri).c_str(), GetAnonyString(value).c_str()); ret = helper->Insert(uri, val); } ReleaseDataShareHelper(helper); if (ret <= 0) { LOGE("set value failed, ret=%{public}d, proxyUri=%{public}s, value=%{public}s", - ret, proxyUri.c_str(), GetAnonyString(value).c_str()); + ret, GetAnonyString(proxyUri).c_str(), GetAnonyString(value).c_str()); return ret; } return ret; -- Gitee From 0b837889300269f90f7871200bff77a0cdcb3e5d Mon Sep 17 00:00:00 2001 From: dinghao Date: Mon, 7 Jul 2025 14:06:16 +0800 Subject: [PATCH 2/2] memcpy_s func modify Signed-off-by: dinghao --- .../src/authentication_v2/auth_stages/auth_credential.cpp | 2 +- .../src/dependency/hichain/hichain_auth_connector.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp index 816627a40..92eed3b7a 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp @@ -508,7 +508,7 @@ int32_t AuthCredentialAgreeState::AgreeCredential(DmAuthScope authorizedScope, authContext->accesser.userId : authContext->accessee.userId; std::string selfCredId = authContext->GetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope); std::string credId; - LOGI("AuthCredentialAgreeState::AgreeCredential agree with accountId %{public}d and param %{public}s.", + LOGI("AuthCredentialAgreeState::AgreeCredential agree with accountId %{public}s and param %{public}s.", GetAnonyInt32(osAccountId), GetAnonyJsonString(authParamsString).c_str()); int32_t ret = authContext->hiChainAuthConnector->AgreeCredential(osAccountId, selfCredId, authParamsString, credId); diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index ab1c4a7e9..fa3e60882 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -500,7 +500,7 @@ int32_t HiChainAuthConnector::GetCredential(std::string &localUdid, int32_t osAc int32_t HiChainAuthConnector::ImportCredential(int32_t osAccountId, int32_t peerOsAccountId, std::string deviceId, std::string publicKey) { - LOGI("start, deviceId: %{public}s, peerOsAccountId: %{public}d", + LOGI("start, deviceId: %{public}s, peerOsAccountId: %{public}s", GetAnonyString(deviceId).c_str(), GetAnonyInt32(peerOsAccountId)); JsonObject jsonObj; jsonObj["osAccountId"] = osAccountId; -- Gitee