diff --git a/interfaces/kits/napi/continuation_manager/js_continuation_manager.cpp b/interfaces/kits/napi/continuation_manager/js_continuation_manager.cpp index 29dcb18d..1c711840 100644 --- a/interfaces/kits/napi/continuation_manager/js_continuation_manager.cpp +++ b/interfaces/kits/napi/continuation_manager/js_continuation_manager.cpp @@ -33,6 +33,7 @@ constexpr int32_t ERR_NOT_OK = -1; constexpr int32_t ARG_COUNT_ONE = 1; constexpr int32_t ARG_COUNT_TWO = 2; constexpr int32_t ARG_COUNT_THREE = 3; +constexpr uint32_t MAX_JSPROCOUNT = 1000000; } void JsContinuationManager::Finalizer(NativeEngine* engine, void* data, void* hint) @@ -490,6 +491,10 @@ bool JsContinuationManager::PraseJson(const napi_env& env, const napi_value& jso napi_value jsProName = nullptr; napi_value jsProValue = nullptr; napi_valuetype jsValueType = napi_undefined; + if (jsProCount > MAX_JSPROCOUNT) { + HILOGE("value of jsProCount is larger than MAX_JSPROCOUNT"); + return false; + } for (uint32_t index = 0; index < jsProCount; index++) { napi_get_element(env, jsProNameList, index, &jsProName); std::string strProName = UnwrapStringFromJS(env, jsProName);