JSON文件中不包含有效配置时,避免段错误。 TSG-9349

This commit is contained in:
zhengchao
2022-01-13 12:06:09 +05:00
parent d2db95e528
commit dd86ba5fc1
2 changed files with 45 additions and 47 deletions

View File

@@ -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);

View File

@@ -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)
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);
}
compile_cnt=cJSON_GetArraySize(compile_array);
if(compile_cnt<=0)
if(compile_cnt>0)
{
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_json,
"have no rules.");
return -1;
}
cJSON_ArrayForEach(compile_obj, compile_array)
{
compile_id=write_compile_line(compile_obj,p_iris, logger);
if(compile_id<0)
cJSON_ArrayForEach(compile_obj, compile_array)
{
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)
{
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);