diff --git a/frameworks/ets/ani/include/sts_common.h b/frameworks/ets/ani/include/sts_common.h index 359947a43308e32874ca843adf4bac57d93f0564..e4043d01c821f9e1d869b5200e062573a41ea077 100644 --- a/frameworks/ets/ani/include/sts_common.h +++ b/frameworks/ets/ani/include/sts_common.h @@ -28,6 +28,7 @@ namespace NotificationSts { using namespace arkts::ani_signature; constexpr int32_t STR_MAX_SIZE = 204; +constexpr int32_t PROFILE_NAME_SIZE = 202; constexpr int32_t LONG_STR_MAX_SIZE = 1028; constexpr int32_t COMMON_TEXT_SIZE = 3074; constexpr int32_t SHORT_TEXT_SIZE = 1026; diff --git a/frameworks/ets/ani/src/sts_disturb_mode.cpp b/frameworks/ets/ani/src/sts_disturb_mode.cpp index 89dec0327a1035de57eab035f15310fa8ad39d01..64de48561557e13560740e329ea676764f06ad3a 100644 --- a/frameworks/ets/ani/src/sts_disturb_mode.cpp +++ b/frameworks/ets/ani/src/sts_disturb_mode.cpp @@ -40,7 +40,8 @@ bool UnwrapDoNotDisturbProfile(ani_env *env, ani_object param, ANS_LOGE("UnwrapDoNotDisturbProfile: get name failed"); return false; } - profile->SetProfileName(nameStr); + std::string profileName = GetResizeStr(nameStr, PROFILE_NAME_SIZE); + profile->SetProfileName(profileName); ani_ref trustlistRef; if (ANI_OK != GetPropertyRef(env, param, "trustlist", isUndefined, trustlistRef) || isUndefined == ANI_TRUE) { ANS_LOGE("UnwrapDoNotDisturbProfile: get trustlist failed");