Skip to content

Commit

Permalink
fix: limit num_of_records_per_req range size (#662)
Browse files Browse the repository at this point in the history
* fix: limit num_of_records_per_req range size

* fix int32 check

* test: modify num_of_records_per_req max value to 32768

* test: modify num_of_records_per_req max value to 32768 on error msg
  • Loading branch information
DuanKuanJun committed May 26, 2023
1 parent 344027b commit 83b5b13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,16 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) {
tools_cJSON_GetObjectItem(json, "num_of_records_per_req");
if (numRecPerReq && numRecPerReq->type == tools_cJSON_Number) {
g_arguments->reqPerReq = (uint32_t)numRecPerReq->valueint;
if (g_arguments->reqPerReq <= 0) goto PARSE_OVER;
if ((int32_t)g_arguments->reqPerReq <= 0) {
errorPrint(" num_of_records_per_req item in json config must over zero. current = %d\n", g_arguments->reqPerReq);
goto PARSE_OVER;
}

if (g_arguments->reqPerReq > 32768) {
errorPrint(" num_of_records_per_req item in json config need less than 32768. current = %d\n", g_arguments->reqPerReq);
goto PARSE_OVER;
}

}

tools_cJSON *prepareRand =
Expand Down

0 comments on commit 83b5b13

Please sign in to comment.