diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 5dfa2e9e910517cec5e27204e5a92b9aa2ad65ee..c8d42903867c5f2cfb28cda43c2096d5474f42d5 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -100,6 +100,10 @@ int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& clickInfo InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); } if (srvHandler != nullptr) { + if (clickInfo.extraInfo.dataSize == 0 || clickInfo.extraInfo.data == nullptr) { + SC_LOG_ERROR(LABEL, "HMAC info is invalid"); + return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; + } return srvHandler->CheckExtraInfo(clickInfo); } return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE; diff --git a/interfaces/inner_api/security_component/include/sec_comp_client.h b/interfaces/inner_api/security_component/include/sec_comp_client.h index fca78d5f19d7cb1a76685082a34f9eb193a57961..d1d0af76b3497729362a7844fc89502062465f10 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_client.h +++ b/interfaces/inner_api/security_component/include/sec_comp_client.h @@ -38,6 +38,8 @@ public: bool VerifySavePermission(AccessToken::AccessTokenID tokenId); sptr GetEnhanceRemoteObject(bool doLoadSa); int32_t PreRegisterSecCompProcess(); + bool IsServiceExist(); + bool LoadService(); void FinishStartSASuccess(const sptr& remoteObject); void FinishStartSAFail(); diff --git a/interfaces/inner_api/security_component/include/sec_comp_kit.h b/interfaces/inner_api/security_component/include/sec_comp_kit.h index 93c7e531c08d711b562178dce43bbb7b26ac0484..554510cd4e3233f6e3226d2c9209a8b8a7e2afbe 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_kit.h +++ b/interfaces/inner_api/security_component/include/sec_comp_kit.h @@ -34,6 +34,8 @@ public: static bool VerifySavePermission(AccessToken::AccessTokenID tokenId); static sptr GetEnhanceRemoteObject(bool isLoad); static int32_t PreRegisterSecCompProcess(); + static bool IsServiceExist(); + static bool LoadService(); }; } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/interfaces/inner_api/security_component/src/sec_comp_client.cpp index 7ce91dc5df616938da8c1ff2b0b0fcb38db67209..ca2847c62995af378b9f8c0b79ea5ed2918c6dc5 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_client.cpp @@ -124,6 +124,16 @@ int32_t SecCompClient::PreRegisterSecCompProcess() return proxy->PreRegisterSecCompProcess(); } +bool SecCompClient::IsServiceExist() +{ + return GetProxy(false) != nullptr; +} + +bool SecCompClient::LoadService() +{ + return GetProxy(true) != nullptr; +} + bool SecCompClient::StartLoadSecCompSa() { { diff --git a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp index a8314fb6208d32422b3f8f6707ae60cdc1f74c64..bd414b64a104ac0e6e67a6cf16277e7976bb2573 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp @@ -138,6 +138,16 @@ int32_t SecCompKit::PreRegisterSecCompProcess() { return SecCompClient::GetInstance().PreRegisterSecCompProcess(); } + +bool SecCompKit::IsServiceExist() +{ + return SecCompClient::GetInstance().IsServiceExist(); +} + +bool SecCompKit::LoadService() +{ + return SecCompClient::GetInstance().LoadService(); +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp index 68376926c9845632791fe9b88e2f7b0fa3133647..4cbfc41ea3c920fc56182a2ab1fc5d0b654c7a95 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp @@ -97,6 +97,11 @@ int32_t SecCompEntity::CheckClickInfo(const SecCompClickEvent& clickInfo) const } res = SecCompEnhanceAdapter::CheckExtraInfo(clickInfo); + if (res == SC_SERVICE_ERROR_CLICK_EVENT_INVALID) { + SC_LOG_ERROR(LABEL, "Click ExtraInfo is invalid"); + return res; + } + if ((res != SC_OK) && (res != SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE)) { SC_LOG_ERROR(LABEL, "HMAC checkout failed"); HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index 9da222fea282e91fdc464172a64b6119c6381f86..7a3e002d93fb7484ddeb27811601b453b8f007d9 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -304,7 +304,7 @@ int32_t SecCompManager::AddSecurityComponentProcess(const SecCompCallerInfo& cal } auto iter = componentMap_.find(caller.pid); - if (iter != componentMap_.end()) { + if (iter == componentMap_.end()) { ProcessCompInfos newProcess; newProcess.isForeground = true; newProcess.tokenId = caller.tokenId; @@ -515,6 +515,7 @@ bool SecCompManager::Initialize() secHandler_ = std::make_shared(secRunner_); DelayExitTask::GetInstance().Init(secHandler_); firstUseDialog_.Init(secHandler_); + SecCompEnhanceAdapter::EnableInputEnhance(); return SecCompPermManager::GetInstance().InitEventHandler(secHandler_); }