From f3dde5a850481aa2c867f3c8f68465bcbf2c1e90 Mon Sep 17 00:00:00 2001 From: gyc Date: Fri, 24 Jun 2022 17:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp | 4 +++- .../accesstoken/src/native_token_info_for_sync_parcel.cpp | 4 +++- frameworks/common/include/parcel_utils.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp index 89766e871..e2873bab3 100644 --- a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp @@ -30,7 +30,9 @@ bool HapTokenInfoForSyncParcel::Marshalling(Parcel& out) const const std::vector& permStateList = this->hapTokenInfoForSyncParams.permStateList; int32_t permStateListSize = static_cast(permStateList.size()); RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); - + if(permStateListSize > MAX_PERMLIST_SIZE) { + return false; + } for (int i = 0; i < permStateListSize; i++) { PermissionStateFullParcel permStateParcel; permStateParcel.permStatFull = permStateList[i]; diff --git a/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp b/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp index 541bbea1d..10adc93e0 100644 --- a/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/native_token_info_for_sync_parcel.cpp @@ -30,7 +30,9 @@ bool NativeTokenInfoForSyncParcel::Marshalling(Parcel& out) const const std::vector& permStateList = this->nativeTokenInfoForSyncParams.permStateList; int32_t permStateListSize = static_cast(permStateList.size()); RETURN_IF_FALSE(out.WriteInt32(permStateListSize)); - + if(permStateListSize > MAX_PERMLIST_SIZE) { + return false; + } for (int i = 0; i < permStateListSize; i++) { PermissionStateFullParcel permStateParcel; permStateParcel.permStatFull = permStateList[i]; diff --git a/frameworks/common/include/parcel_utils.h b/frameworks/common/include/parcel_utils.h index ddc87d688..d6b7e8b6b 100644 --- a/frameworks/common/include/parcel_utils.h +++ b/frameworks/common/include/parcel_utils.h @@ -15,6 +15,7 @@ #ifndef PARCEL_UTILS_H #define PARCEL_UTILS_H +#define MAX_PERMLIST_SIZE 256 namespace OHOS { namespace Security { namespace AccessToken { -- Gitee