From 40f63753d30ba9d5893d8fc772eed1c5af8b9faf Mon Sep 17 00:00:00 2001 From: gyc Date: Fri, 24 Jun 2022 16:51:12 +0800 Subject: [PATCH] protect --- .../accesstoken/src/hap_token_info_for_sync_parcel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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..68e2ffbf4 100644 --- a/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp +++ b/frameworks/accesstoken/src/hap_token_info_for_sync_parcel.cpp @@ -18,6 +18,7 @@ #include "parcel_utils.h" #include "permission_state_full_parcel.h" +#define MAX_PERMLIST_SIZE 256 namespace OHOS { namespace Security { namespace AccessToken { @@ -30,7 +31,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]; -- Gitee