diff --git a/frameworks/ets/ani/include/sts_common.h b/frameworks/ets/ani/include/sts_common.h index 0417f15edc1466180f0fa9caa8c8a9759f016bd1..2d5b698b03edd1d2945c1c1407c4f89b2a100655 100644 --- a/frameworks/ets/ani/include/sts_common.h +++ b/frameworks/ets/ani/include/sts_common.h @@ -25,6 +25,7 @@ namespace OHOS { namespace NotificationSts { 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");