From ec49b0356c262e2d8142f174c62702639c7478d6 Mon Sep 17 00:00:00 2001 From: huaqingsimeng <1004904143@qq.com> Date: Mon, 29 May 2023 19:42:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9find=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=20=E6=94=B9=E4=B8=BAstart=5Fwith?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huaqingsimeng --- utils/src/b_error/b_excep_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/src/b_error/b_excep_utils.cpp b/utils/src/b_error/b_excep_utils.cpp index 5a6ad2f91..5a9866e3a 100644 --- a/utils/src/b_error/b_excep_utils.cpp +++ b/utils/src/b_error/b_excep_utils.cpp @@ -30,8 +30,8 @@ void BExcepUltils::VerifyPath(const string_view &path, bool isExtension) auto ret = canonicalize(path.data()); string absPath = ret.c_str(); if (isExtension && - absPath.find(string(BConstants::PATH_BUNDLE_BACKUP_HOME) - .append(BConstants::SA_BUNDLE_BACKUP_RESTORE)) == std::string::npos) { + !absPath.startswith( + string(BConstants::PATH_BUNDLE_BACKUP_HOME).append(BConstants::SA_BUNDLE_BACKUP_RESTORE))) { throw BError(BError::Codes::EXT_INVAL_ARG, "Invalid path, not in backup restore path"); } } catch (const rust::Error &e) { -- Gitee From 1934591bd7b44b66049238ca58456918ed595dfd Mon Sep 17 00:00:00 2001 From: huaqingsimeng <1004904143@qq.com> Date: Thu, 8 Jun 2023 16:32:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8Dextensi?= =?UTF-8?q?on=E7=AB=AF=E4=B8=8E=E6=9C=8D=E5=8A=A1=E7=AB=AFipc=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A0=A1=E9=AA=8C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huaqingsimeng --- services/backup_sa/src/module_ipc/service.cpp | 6 ------ utils/src/b_error/b_excep_utils.cpp | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/services/backup_sa/src/module_ipc/service.cpp b/services/backup_sa/src/module_ipc/service.cpp index baddb4118..a2855001c 100644 --- a/services/backup_sa/src/module_ipc/service.cpp +++ b/services/backup_sa/src/module_ipc/service.cpp @@ -108,12 +108,6 @@ string Service::VerifyCallerAndGetCallerName() uint32_t tokenCaller = IPCSkeleton::GetCallingTokenID(); int tokenType = Security::AccessToken::AccessTokenKit::GetTokenType(tokenCaller); if (tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_HAP) { - const string permission = "ohos.permission.BACKUP"; - int ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(tokenCaller, permission); - if (ret == Security::AccessToken::TypePermissionState::PERMISSION_DENIED) { - throw BError(BError::Codes::SA_INVAL_ARG, - string("Permission denied, token type is ").append(to_string(tokenType))); - } Security::AccessToken::HapTokenInfo hapTokenInfo; if (Security::AccessToken::AccessTokenKit::GetHapTokenInfo(tokenCaller, hapTokenInfo) != 0) { throw BError(BError::Codes::SA_INVAL_ARG, "Get hap token info failed"); diff --git a/utils/src/b_error/b_excep_utils.cpp b/utils/src/b_error/b_excep_utils.cpp index 5a9866e3a..5a6ad2f91 100644 --- a/utils/src/b_error/b_excep_utils.cpp +++ b/utils/src/b_error/b_excep_utils.cpp @@ -30,8 +30,8 @@ void BExcepUltils::VerifyPath(const string_view &path, bool isExtension) auto ret = canonicalize(path.data()); string absPath = ret.c_str(); if (isExtension && - !absPath.startswith( - string(BConstants::PATH_BUNDLE_BACKUP_HOME).append(BConstants::SA_BUNDLE_BACKUP_RESTORE))) { + absPath.find(string(BConstants::PATH_BUNDLE_BACKUP_HOME) + .append(BConstants::SA_BUNDLE_BACKUP_RESTORE)) == std::string::npos) { throw BError(BError::Codes::EXT_INVAL_ARG, "Invalid path, not in backup restore path"); } } catch (const rust::Error &e) { -- Gitee