summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2022-01-13 12:06:09 +0500
committerzhengchao <[email protected]>2022-01-13 12:06:09 +0500
commitdd86ba5fc1d71296c9dab952894e4b9f0c6488c4 (patch)
tree5406d2833e9f3dd7561457acdb7f7c4f197685d3
parentd2db95e528f26200c5591b9d9e02b40acdfa947e (diff)
JSON文件中不包含有效配置时,避免段错误。 TSG-9349v3.5.3
-rw-r--r--src/entry/Maat_api.cpp14
-rw-r--r--src/entry/json2iris.cpp78
2 files changed, 45 insertions, 47 deletions
diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp
index b9bbf2a..8f94508 100644
--- a/src/entry/Maat_api.cpp
+++ b/src/entry/Maat_api.cpp
@@ -1637,10 +1637,10 @@ int Maat_scan_intval(Maat_feather_t feather,int table_id
}
-int Maat_similar_scan_string(Maat_feather_t feather,int table_id
- ,const char* data,int data_len
- ,struct Maat_rule_t*result,int rule_num
- ,scan_status_t* mid,int thread_num)
+int Maat_similar_scan_string(Maat_feather_t feather, int table_id,
+ const char* data, int data_len,
+ struct Maat_rule_t*result, int rule_num,
+ scan_status_t* mid, int thread_num)
{
int hit_region_cnt=0,compile_ret=0;
struct _OUTER_scan_status_t* _mid=NULL;
@@ -1676,7 +1676,11 @@ int Maat_similar_scan_string(Maat_feather_t feather,int table_id
struct Maat_table_runtime* table_rt=Maat_table_runtime_get(my_scanner->table_rt_mgr, p_table->table_id);
- GIE_handle_t* gie_handle=table_rt->similar.gie_handle;
+ GIE_handle_t* gie_handle=table_rt->similar.gie_handle;
+ if(gie_handle==NULL)
+ {
+ return 0;
+ }
INC_SCANNER_REF(my_scanner,thread_num);
alignment_int64_array_add(_feather->thread_call_cnt, thread_num, 1);
diff --git a/src/entry/json2iris.cpp b/src/entry/json2iris.cpp
index bebf4be..458e590 100644
--- a/src/entry/json2iris.cpp
+++ b/src/entry/json2iris.cpp
@@ -1082,7 +1082,7 @@ int write_group_rule(cJSON *group_json, int parent_id, int parent_type, int trac
ret=write_region_rule(region_rule, tracking_compile_id, group_info->group_id, p_iris, logger);
if(ret<0)
{
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
+ MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_json,
"compile rule %d write region error.", tracking_compile_id);
return -1;
}
@@ -1120,7 +1120,7 @@ int write_group_rule(cJSON *group_json, int parent_id, int parent_type, int trac
}
if(ret<0)
{
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
+ MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_json,
"%s rule %d write group error.", _str_parent_type[parent_type], parent_id);
return -1;
}
@@ -1137,7 +1137,7 @@ int write_iris(cJSON *json, struct iris_description_t *p_iris, void* logger)
static struct group_info_t* parent_group=NULL;
const char* parent_group_name=NULL;
- plug_tables=cJSON_GetObjectItem(json,"plugin_table");
+ plug_tables=cJSON_GetObjectItem(json, "plugin_table");
if(NULL!=plug_tables)
{
i=0;
@@ -1175,53 +1175,47 @@ int write_iris(cJSON *json, struct iris_description_t *p_iris, void* logger)
}
}
+ compile_cnt=0;
compile_array=cJSON_GetObjectItem(json,"rules");
- if(compile_array==NULL)
- {
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
- "have no rules.");
- return -1;
-
- }
- compile_cnt=cJSON_GetArraySize(compile_array);
- if(compile_cnt<=0)
+ if(compile_array!=NULL)
{
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
- "have no rules.");
- return -1;
+ compile_cnt=cJSON_GetArraySize(compile_array);
}
- cJSON_ArrayForEach(compile_obj, compile_array)
+ if(compile_cnt>0)
{
- compile_id=write_compile_line(compile_obj,p_iris, logger);
- if(compile_id<0)
- {
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
- "In %d compile rule.",i);
- return -1;
- }
- group_array=cJSON_GetObjectItem(compile_obj, "groups");
- if(group_array==NULL)
- {
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
- "compile rule %d have no group.",compile_id);
- return -1;
- }
- group_cnt=cJSON_GetArraySize(group_array);
- if(group_cnt<=0)
+ cJSON_ArrayForEach(compile_obj, compile_array)
{
- MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
- "compile rule %d have no groups.",compile_id);
- return -1;
- }
- i=0;
- cJSON_ArrayForEach(group_obj, group_array)
- {
- ret=write_group_rule(group_obj, compile_id, PARENT_TYPE_COMPILE, compile_id, i, p_iris, logger);
- if(ret<0)
+ compile_id=write_compile_line(compile_obj,p_iris, logger);
+ if(compile_id<0)
{
+ MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_json,
+ "In %d compile rule.", i);
return -1;
}
- i++;
+ group_array=cJSON_GetObjectItem(compile_obj, "groups");
+ if(group_array==NULL)
+ {
+ MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_json,
+ "compile rule %d have no group.",compile_id);
+ return -1;
+ }
+ group_cnt=cJSON_GetArraySize(group_array);
+ if(group_cnt<=0)
+ {
+ MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_json,
+ "compile rule %d have no groups.",compile_id);
+ return -1;
+ }
+ i=0;
+ cJSON_ArrayForEach(group_obj, group_array)
+ {
+ ret=write_group_rule(group_obj, compile_id, PARENT_TYPE_COMPILE, compile_id, i, p_iris, logger);
+ if(ret<0)
+ {
+ return -1;
+ }
+ i++;
+ }
}
}
ret=write_index_file(p_iris, logger);