From 2c2fb7e9dbc99598253404071bb6d7a366720b4a Mon Sep 17 00:00:00 2001 From: zhanglei Date: Wed, 18 Jun 2025 11:20:33 +0800 Subject: [PATCH 1/2] update Signed-off-by: zhanglei --- common/src/interfaces/access_control_profile.cpp | 3 --- common/src/interfaces/accessee.cpp | 1 - common/src/interfaces/accesser.cpp | 1 - .../core/src/distributed_device_profile_stub.cpp | 9 +++++++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/interfaces/access_control_profile.cpp b/common/src/interfaces/access_control_profile.cpp index 07fc60a0..a77bd791 100644 --- a/common/src/interfaces/access_control_profile.cpp +++ b/common/src/interfaces/access_control_profile.cpp @@ -260,13 +260,10 @@ std::string AccessControlProfile::dump() const cJSON_AddNumberToObject(json, ACCESS_CONTROL_ID.c_str(), accessControlId_); cJSON_AddNumberToObject(json, ACCESSER_ID.c_str(), accesserId_); cJSON_AddNumberToObject(json, ACCESSEE_ID.c_str(), accesseeId_); - cJSON_AddStringToObject(json, SESSION_KEY.c_str(), sessionKey_.c_str()); cJSON_AddNumberToObject(json, BIND_TYPE.c_str(), bindType_); cJSON_AddNumberToObject(json, AUTHENTICATION_TYPE.c_str(), authenticationType_); cJSON_AddNumberToObject(json, BIND_LEVEL.c_str(), bindLevel_); cJSON_AddNumberToObject(json, STATUS.c_str(), status_); - cJSON_AddNumberToObject(json, VALID_PERIOD.c_str(), validPeriod_); - cJSON_AddNumberToObject(json, LAST_AUTH_TIME.c_str(), lastAuthTime_); cJSON_AddStringToObject(json, TRUST_DEVICE_ID.c_str(), ProfileUtils::GetAnonyString(trustDeviceId_).c_str()); cJSON_AddNumberToObject(json, DEVICE_ID_TYPE.c_str(), deviceIdType_); cJSON_AddStringToObject(json, DEVICE_ID_HASH.c_str(), deviceIdHash_.c_str()); diff --git a/common/src/interfaces/accessee.cpp b/common/src/interfaces/accessee.cpp index ede75755..d647404c 100644 --- a/common/src/interfaces/accessee.cpp +++ b/common/src/interfaces/accessee.cpp @@ -266,7 +266,6 @@ std::string Accessee::dump() const cJSON_AddStringToObject(json, ACCESSEE_DEVICE_NAME.c_str(), ProfileUtils::GetAnonyString(accesseeDeviceName_).c_str()); cJSON_AddStringToObject(json, ACCESSEE_SERVICE_NAME.c_str(), accesseeServiceName_.c_str()); - cJSON_AddNumberToObject(json, ACCESSEE_CREDENTIAL_ID.c_str(), accesseeCredentialId_); cJSON_AddStringToObject(json, ACCESSEE_CREDENTIAL_ID_STR.c_str(), accesseeCredentialIdStr_.c_str()); cJSON_AddNumberToObject(json, ACCESSEE_STATUS.c_str(), accesseeStatus_); cJSON_AddNumberToObject(json, ACCESSEE_SESSION_KEY_ID.c_str(), accesseeSessionKeyId_); diff --git a/common/src/interfaces/accesser.cpp b/common/src/interfaces/accesser.cpp index aa7b4faa..04346db5 100644 --- a/common/src/interfaces/accesser.cpp +++ b/common/src/interfaces/accesser.cpp @@ -264,7 +264,6 @@ std::string Accesser::dump() const cJSON_AddStringToObject(json, ACCESSER_DEVICE_NAME.c_str(), ProfileUtils::GetAnonyString(accesserDeviceName_).c_str()); cJSON_AddStringToObject(json, ACCESSER_SERVICE_NAME.c_str(), accesserServiceName_.c_str()); - cJSON_AddNumberToObject(json, ACCESSER_CREDENTIAL_ID.c_str(), accesserCredentialId_); cJSON_AddStringToObject(json, ACCESSER_CREDENTIAL_ID_STR.c_str(), accesserCredentialIdStr_.c_str()); cJSON_AddNumberToObject(json, ACCESSER_STATUS.c_str(), accesserStatus_); cJSON_AddNumberToObject(json, ACCESSER_SESSION_KEY_ID.c_str(), accesserSessionKeyId_); diff --git a/old/services/core/src/distributed_device_profile_stub.cpp b/old/services/core/src/distributed_device_profile_stub.cpp index bc257720..ad9dcc14 100644 --- a/old/services/core/src/distributed_device_profile_stub.cpp +++ b/old/services/core/src/distributed_device_profile_stub.cpp @@ -759,15 +759,18 @@ int32_t DistributedDeviceProfileStub::PutSessionKeyInner(MessageParcel& data, Me int32_t sessionKeyId = 0; READ_HELPER(data, Uint32, userId); if (!IpcUtils::UnMarshalling(data, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().PutSessionKey(userId, sessionKey, sessionKeyId); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } WRITE_HELPER(reply, Int32, sessionKeyId); + sessionKey.clear(); return DP_SUCCESS; } @@ -781,13 +784,16 @@ int32_t DistributedDeviceProfileStub::GetSessionKeyInner(MessageParcel& data, Me READ_HELPER(data, Int32, sessionKeyId); int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().GetSessionKey(userId, sessionKeyId, sessionKey); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } if (!IpcUtils::Marshalling(reply, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } + sessionKey.clear(); return DP_SUCCESS; } @@ -800,14 +806,17 @@ int32_t DistributedDeviceProfileStub::UpdateSessionKeyInner(MessageParcel& data, READ_HELPER(data, Uint32, userId); READ_HELPER(data, Int32, sessionKeyId); if (!IpcUtils::UnMarshalling(data, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UpdateSessionKey(userId, sessionKeyId, sessionKey); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } + sessionKey.clear(); return DP_SUCCESS; } -- Gitee From ae2c329b92feb74a979c5e29749073054afacc99 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Thu, 19 Jun 2025 11:26:47 +0800 Subject: [PATCH 2/2] update Signed-off-by: zhanglei --- .../core/src/distributed_device_profile_stub_new.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/core/src/distributed_device_profile_stub_new.cpp b/services/core/src/distributed_device_profile_stub_new.cpp index 19e7fb23..ec4f631a 100644 --- a/services/core/src/distributed_device_profile_stub_new.cpp +++ b/services/core/src/distributed_device_profile_stub_new.cpp @@ -391,15 +391,18 @@ int32_t DistributedDeviceProfileStubNew::PutSessionKeyInner(MessageParcel& data, int32_t sessionKeyId = 0; READ_HELPER(data, Uint32, userId); if (!IpcUtils::UnMarshalling(data, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } int32_t ret = PutSessionKey(userId, sessionKey, sessionKeyId); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } WRITE_HELPER(reply, Int32, sessionKeyId); + sessionKey.clear(); return DP_SUCCESS; } @@ -413,13 +416,16 @@ int32_t DistributedDeviceProfileStubNew::GetSessionKeyInner(MessageParcel& data, READ_HELPER(data, Int32, sessionKeyId); int32_t ret = GetSessionKey(userId, sessionKeyId, sessionKey); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } if (!IpcUtils::Marshalling(reply, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } + sessionKey.clear(); return DP_SUCCESS; } @@ -432,14 +438,17 @@ int32_t DistributedDeviceProfileStubNew::UpdateSessionKeyInner(MessageParcel& da READ_HELPER(data, Uint32, userId); READ_HELPER(data, Int32, sessionKeyId); if (!IpcUtils::UnMarshalling(data, sessionKey)) { + sessionKey.clear(); HILOGE("dp ipc write parcel fail"); return DP_WRITE_PARCEL_FAIL; } int32_t ret = UpdateSessionKey(userId, sessionKeyId, sessionKey); if (!reply.WriteInt32(ret)) { + sessionKey.clear(); HILOGE("Write reply failed"); return DP_WRITE_PARCEL_FAIL; } + sessionKey.clear(); return DP_SUCCESS; } -- Gitee