From 3fbe31b1289522910ca640f20e2f10b9c539597e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 30 May 2024 16:31:24 +0800 Subject: [PATCH 1/2] fix: add check childtableFrom and To valid --- src/benchJsonOpt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 4f7da1c2..4f36163e 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -937,6 +937,16 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) { } } + // check childtable_from and childtable_to valid + if (superTable->childTblFrom >= superTable->childTblCount) { + errorPrint("childtable_from(%"PRId64") is equal or large than childtable_count(%"PRId64")\n", superTable->childTblFrom, superTable->childTblCount); + return -1; + } + if (superTable->childTblTo > superTable->childTblCount) { + errorPrint("childtable_to(%"PRId64") is large than childtable_count(%"PRId64")\n", superTable->childTblTo, superTable->childTblCount); + return -1; + } + tools_cJSON *continueIfFail = tools_cJSON_GetObjectItem(stbInfo, "continue_if_fail"); // yes, no, if (tools_cJSON_IsString(continueIfFail)) { From 934ff887bed271a104464c8a11b56ba7bc099bea Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 30 May 2024 16:45:18 +0800 Subject: [PATCH 2/2] fix: add json config invlaid tips --- src/benchJsonOpt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 4f36163e..45f10b83 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -930,7 +930,7 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) { if (tools_cJSON_IsNumber(childTbl_to)) { superTable->childTblTo = childTbl_to->valueint; if (superTable->childTblTo < superTable->childTblFrom) { - errorPrint("child table _to_ is invalid number," + errorPrint("json config invalid. child table _to_ is invalid number," "%"PRId64" < %"PRId64"\n", superTable->childTblTo, superTable->childTblFrom); return -1; @@ -939,11 +939,11 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) { // check childtable_from and childtable_to valid if (superTable->childTblFrom >= superTable->childTblCount) { - errorPrint("childtable_from(%"PRId64") is equal or large than childtable_count(%"PRId64")\n", superTable->childTblFrom, superTable->childTblCount); + errorPrint("json config invalid. childtable_from(%"PRId64") is equal or large than childtable_count(%"PRId64")\n", superTable->childTblFrom, superTable->childTblCount); return -1; } if (superTable->childTblTo > superTable->childTblCount) { - errorPrint("childtable_to(%"PRId64") is large than childtable_count(%"PRId64")\n", superTable->childTblTo, superTable->childTblCount); + errorPrint("json config invalid. childtable_to(%"PRId64") is large than childtable_count(%"PRId64")\n", superTable->childTblTo, superTable->childTblCount); return -1; }