From 4bbd4d97679a378c202df53c88b44e0402def371 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 25 May 2023 19:03:48 +0800 Subject: [PATCH 1/4] fix: limit num_of_records_per_req range size --- src/benchJsonOpt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 41592b42..72f0a017 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -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 (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 > 10000) { + errorPrint(" num_of_records_per_req item in json config need less than 10000. current = %d\n", g_arguments->reqPerReq); + goto PARSE_OVER; + } + } tools_cJSON *prepareRand = From f1562320078f7a45bb81fa0b3e0d1c6c37f5f5eb Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 26 May 2023 11:09:51 +0800 Subject: [PATCH 2/4] fix int32 check --- src/benchJsonOpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 72f0a017..595b9c86 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1176,7 +1176,7 @@ 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) { + 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; } From 3f2a8e5f68a8ddb4198a3ceece0e5a3b452e9c1c Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 26 May 2023 14:05:40 +0800 Subject: [PATCH 3/4] test: modify num_of_records_per_req max value to 32768 --- src/benchJsonOpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 595b9c86..4be90e11 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1181,7 +1181,7 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) { goto PARSE_OVER; } - if (g_arguments->reqPerReq > 10000) { + if (g_arguments->reqPerReq > 32768) { errorPrint(" num_of_records_per_req item in json config need less than 10000. current = %d\n", g_arguments->reqPerReq); goto PARSE_OVER; } From 7e0812e7493b40244eb17f56f017f0c004bf6cee Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 26 May 2023 14:29:45 +0800 Subject: [PATCH 4/4] test: modify num_of_records_per_req max value to 32768 on error msg --- src/benchJsonOpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 4be90e11..c48e6b28 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1182,7 +1182,7 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) { } if (g_arguments->reqPerReq > 32768) { - errorPrint(" num_of_records_per_req item in json config need less than 10000. current = %d\n", g_arguments->reqPerReq); + errorPrint(" num_of_records_per_req item in json config need less than 32768. current = %d\n", g_arguments->reqPerReq); goto PARSE_OVER; }