diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 9c9c4f4f4b5b969c5d1b10d50b3c31d069001b29..83a864108874146986bc8c95fa9b68ceafa17402 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 c6c49599d689bb3f18ccd687eb7444bdadd9f809..6487eaa0c8ceaaa4948a1ee2b92df03c494748e8 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 56b222391d9e03d8cad29ee85f89d585764e72ed..6c46b04fb1ba0000721fdb1a79c1269b33218430 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; }