From 02d467f60e27d0b3deafa552df552cdeb4c0c4ae Mon Sep 17 00:00:00 2001 From: wanghang Date: Thu, 15 Dec 2022 06:37:04 +0000 Subject: [PATCH] IssueNo:#I66B7E Description:delete checkBundleName switch Sig:SIG_ApplicaitonFramework Feature or Bugfix:Feature Binary Source:No Signed-off-by: wanghang Change-Id: Ibe9c7322315452712bdb4474fd65896beb53f903 --- .../include/bundle_install_checker.h | 2 ++ .../bundlemgr/src/bundle_install_checker.cpp | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/bundlemgr/include/bundle_install_checker.h b/services/bundlemgr/include/bundle_install_checker.h index 3289d7b2d5..c1eb313ba6 100644 --- a/services/bundlemgr/include/bundle_install_checker.h +++ b/services/bundlemgr/include/bundle_install_checker.h @@ -146,6 +146,8 @@ private: ErrCode CheckMainElement(const InnerBundleInfo &info); + ErrCode CheckBundleName(const std::string &provisionInfoBundleName, const std::string &bundleName); + void FetchPrivilegeCapabilityFromPreConfig( const std::string &bundleName, const std::string &appSignature, diff --git a/services/bundlemgr/src/bundle_install_checker.cpp b/services/bundlemgr/src/bundle_install_checker.cpp index 457415d3f9..a7e1bd6db9 100644 --- a/services/bundlemgr/src/bundle_install_checker.cpp +++ b/services/bundlemgr/src/bundle_install_checker.cpp @@ -232,6 +232,11 @@ ErrCode BundleInstallChecker::ParseHapFiles( APP_LOGE("bundle parse failed %{public}d", result); return result; } + result = CheckBundleName(provisionInfo.bundleInfo.bundleName, newInfo.GetBundleName()); + if (result != ERR_OK) { + APP_LOGE("check provision bundleName failed"); + return result; + } if (newInfo.HasEntry()) { if (isContainEntry_) { @@ -281,6 +286,23 @@ ErrCode BundleInstallChecker::ParseHapFiles( return result; } +ErrCode BundleInstallChecker::CheckBundleName(const std::string &provisionBundleName, const std::string &bundleName) +{ + APP_LOGD("CheckBundleName provisionBundleName:%{public}s, bundleName:%{public}s", + provisionBundleName.c_str(), bundleName.c_str()); + if (provisionBundleName.empty() || bundleName.empty()) { + APP_LOGE("CheckBundleName provisionBundleName:%{public}s, bundleName:%{public}s failed", provisionBundleName.c_str(), + bundleName.c_str()); + return ERR_APPEXECFWK_INSTALL_FAILED_BUNDLE_SIGNATURE_VERIFICATION_FAILURE; + } + if (provisionBundleName == bundleName) { + return ERR_OK; + } + APP_LOGE("CheckBundleName failed provisionBundleName:%{public}s, bundleName:%{public}s", + provisionBundleName.c_str(), bundleName.c_str()); + return ERR_APPEXECFWK_INSTALL_FAILED_BUNDLE_SIGNATURE_VERIFICATION_FAILURE; +} + void BundleInstallChecker::CollectProvisionInfo( const Security::Verify::ProvisionInfo &provisionInfo, const AppPrivilegeCapability &appPrivilegeCapability, -- Gitee