!393 jsProCount添加入参校验

Merge pull request !393 from 杜智海/master
This commit is contained in:
openharmony_ci 2022-09-20 08:26:41 +00:00 committed by Gitee
commit ab8251468e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -33,6 +33,7 @@ constexpr int32_t ERR_NOT_OK = -1;
constexpr int32_t ARG_COUNT_ONE = 1; constexpr int32_t ARG_COUNT_ONE = 1;
constexpr int32_t ARG_COUNT_TWO = 2; constexpr int32_t ARG_COUNT_TWO = 2;
constexpr int32_t ARG_COUNT_THREE = 3; constexpr int32_t ARG_COUNT_THREE = 3;
constexpr uint32_t MAX_JSPROCOUNT = 1000000;
} }
void JsContinuationManager::Finalizer(NativeEngine* engine, void* data, void* hint) 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 jsProName = nullptr;
napi_value jsProValue = nullptr; napi_value jsProValue = nullptr;
napi_valuetype jsValueType = napi_undefined; 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++) { for (uint32_t index = 0; index < jsProCount; index++) {
napi_get_element(env, jsProNameList, index, &jsProName); napi_get_element(env, jsProNameList, index, &jsProName);
std::string strProName = UnwrapStringFromJS(env, jsProName); std::string strProName = UnwrapStringFromJS(env, jsProName);