From 8e13462f4a15c0a244f4a73d94bf7a2d34556ef9 Mon Sep 17 00:00:00 2001 From: AXYChen Date: Tue, 1 Apr 2025 20:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=92=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: AXYChen Change-Id: I43864b4cd89b42a5e05bb205838389cb05070d2f --- .../src/sec_comp_enhance_adapter.cpp | 2 +- .../src/sec_comp_client.cpp | 69 +++++++++++-------- .../sa/sa_main/sec_comp_service.cpp | 2 +- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 9c9c4f4..83a8641 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -185,7 +185,7 @@ static bool WriteMessageParcel(MessageParcel& tmpData, SecCompRawdata& data) static bool ReadMessageParcel(SecCompRawdata& tmpData, MessageParcel& data) { - int32_t size = tmpData.size; + uint32_t size = tmpData.size; const void *iter = tmpData.data; if (iter == nullptr) { diff --git a/frameworks/inner_api/security_component/src/sec_comp_client.cpp b/frameworks/inner_api/security_component/src/sec_comp_client.cpp index c6c4959..6487eaa 100644 --- a/frameworks/inner_api/security_component/src/sec_comp_client.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_client.cpp @@ -102,15 +102,20 @@ int32_t SecCompClient::RegisterSecurityComponent(SecCompType type, return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!deserializedReply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Register read res failed."); + if (res != SC_OK) { + SC_LOG_ERROR(LABEL, "Register IPC failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (res != SC_OK) { + int32_t serviceRes; + if (!deserializedReply.ReadInt32(serviceRes)) { + SC_LOG_ERROR(LABEL, "Register read serviceRes failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (serviceRes != SC_OK) { scId = INVALID_SC_ID; - SC_LOG_ERROR(LABEL, "Register request failed, result: %{public}d.", res); - return res; + return serviceRes; } if (!deserializedReply.ReadInt32(scId)) { @@ -163,17 +168,18 @@ int32_t SecCompClient::UpdateSecurityComponent(int32_t scId, const std::string& return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!deserializedReply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Update read res failed."); + if (res != SC_OK) { + SC_LOG_ERROR(LABEL, "Update IPC failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (res != SC_OK) { - SC_LOG_ERROR(LABEL, "Update request failed, result: %{public}d.", res); - return res; + int32_t serviceRes; + if (!deserializedReply.ReadInt32(serviceRes)) { + SC_LOG_ERROR(LABEL, "Update read res failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - return res; + return serviceRes; } int32_t SecCompClient::UnregisterWriteToRawdata(int32_t scId, SecCompRawdata& rawData) @@ -216,16 +222,18 @@ int32_t SecCompClient::UnregisterSecurityComponent(int32_t scId) return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!deserializedReply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Unregister read res failed."); + if (res != SC_OK) { + SC_LOG_ERROR(LABEL, "Unregister IPC failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (res != SC_OK) { - SC_LOG_ERROR(LABEL, "Unregister request failed, result: %{public}d.", res); - return res; + int32_t serviceRes; + if (!deserializedReply.ReadInt32(serviceRes)) { + SC_LOG_ERROR(LABEL, "Unregister read res failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - return res; + + return serviceRes; } int32_t SecCompClient::ReportWriteToRawdata(SecCompInfo& secCompInfo, SecCompRawdata& rawData) @@ -284,14 +292,19 @@ int32_t SecCompClient::ReportSecurityComponentClickEvent(SecCompInfo& secCompInf return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!deserializedReply.ReadInt32(res)) { + if (res != SC_OK) { + SC_LOG_ERROR(LABEL, "Report IPC failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + int32_t serviceRes; + if (!deserializedReply.ReadInt32(serviceRes)) { SC_LOG_ERROR(LABEL, "Report read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (res != SC_OK) { - SC_LOG_ERROR(LABEL, "Report request failed, result: %{public}d.", res); - return res; + if (serviceRes != SC_OK) { + return serviceRes; } if (!deserializedReply.ReadString(message)) { @@ -357,16 +370,18 @@ int32_t SecCompClient::PreRegisterSecCompProcess() return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!deserializedReply.ReadInt32(res)) { + if (res != SC_OK) { + SC_LOG_ERROR(LABEL, "PreRegister IPC failed."); + return res; + } + + int32_t serviceRes; + if (!deserializedReply.ReadInt32(serviceRes)) { SC_LOG_ERROR(LABEL, "PreRegister read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (res != SC_OK) { - SC_LOG_ERROR(LABEL, "PreRegister request failed, result: %{public}d.", res); - return res; - } - return res; + return serviceRes; } bool SecCompClient::IsServiceExist() diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.cpp b/services/security_component_service/sa/sa_main/sec_comp_service.cpp index 56b2223..6c46b04 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_service.cpp @@ -191,7 +191,7 @@ int32_t SecCompService::ParseParams(const std::string& componentInfo, int32_t SecCompService::WriteError(int32_t res, SecCompRawdata& rawReply) { MessageParcel replyParcel; - if (!replyParcel.WriteUint32(res)) { + if (!replyParcel.WriteInt32(res)) { SC_LOG_ERROR(LABEL, "Write error res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } -- Gitee