Enforce parameter check in Maat_initiate function.
This commit is contained in:
@@ -155,7 +155,7 @@ enum MAAT_SCAN_OPT
|
||||
MAAT_SET_SCAN_DISTRICT=1 //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1.DEFAULT: no default.
|
||||
};
|
||||
//return 0 if success, return -1 when failed;
|
||||
int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCAN_OPT,const void* value,int size);
|
||||
int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCAN_OPT type,const void* value,int size);
|
||||
|
||||
//Return hit rule number, return -1 when error occurs,return -2 when hit current region
|
||||
//mid MUST set NULL before fist call
|
||||
|
||||
@@ -518,6 +518,13 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
|
||||
int Maat_initiate_feather(Maat_feather_t feather)
|
||||
{
|
||||
_Maat_feather_t* _feather=(_Maat_feather_t*)feather;
|
||||
if(strlen(_feather->full_dir)==0)
|
||||
{
|
||||
MESA_handle_runtime_log(_feather->logger,RLOG_LV_FATAL,maat_module ,
|
||||
"At initiation: NO FULL_CFG_DIR or JSON_FILE_PATH. ");
|
||||
|
||||
return -1;
|
||||
}
|
||||
config_monitor_traverse(_feather->maat_version,
|
||||
_feather->full_dir,
|
||||
maat_start_cb,
|
||||
@@ -540,9 +547,19 @@ int Maat_initiate_feather(Maat_feather_t feather)
|
||||
}
|
||||
if(strlen(_feather->stat_file)==0)
|
||||
{
|
||||
_feather->perf_on=0;
|
||||
if(_feather->stat_on==1)
|
||||
{
|
||||
MESA_handle_runtime_log(_feather->logger,RLOG_LV_FATAL,maat_module ,
|
||||
"At initiation: MAAT_OPT_STAT_FILE_PATH not set,TURN OFF STAT trigger.");
|
||||
}
|
||||
_feather->stat_on=0;
|
||||
}
|
||||
if(_feather->stat_on==0&&_feather->perf_on==1)
|
||||
{
|
||||
MESA_handle_runtime_log(_feather->logger,RLOG_LV_FATAL,maat_module ,
|
||||
"At initiation: STAT tirigger OFF, TURN OFF PERF trigger.");
|
||||
_feather->perf_on=0;
|
||||
}
|
||||
maat_stat_init(_feather);
|
||||
|
||||
pthread_t cfg_mon_t;
|
||||
@@ -1382,7 +1399,7 @@ int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCA
|
||||
{
|
||||
struct _Maat_feather_t* _feather=(_Maat_feather_t*)feather;
|
||||
struct _OUTER_scan_status_t* _mid=NULL;
|
||||
int ret=0,map_ret=-1;
|
||||
int map_ret=-1;
|
||||
_mid=grab_mid(mid,_feather, 0, 0);
|
||||
if(*mid==NULL)
|
||||
{
|
||||
@@ -1395,16 +1412,15 @@ int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCA
|
||||
map_ret=map_str2int(_feather->scanner->district_map,(const char*)value,&(_mid->district_id));
|
||||
if(map_ret<0)
|
||||
{
|
||||
//May be the district have not effect yet.
|
||||
//May be the district not effected yet.
|
||||
}
|
||||
_mid->is_set_district=1;
|
||||
ret=0;
|
||||
break;
|
||||
default:
|
||||
ret=-1;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
void Maat_clean_status(scan_status_t* mid)
|
||||
{
|
||||
|
||||
@@ -275,7 +275,7 @@ int test_expr_plus(Maat_feather_t feather,const char* table_name,scan_status_t*
|
||||
mid, 0);
|
||||
if(ret>0)
|
||||
{
|
||||
printf("Should not hit without set district.\n");
|
||||
printf("Should not hit without setting district.\n");
|
||||
return -1;
|
||||
}
|
||||
ret=Maat_set_scan_status(feather, mid, MAAT_SET_SCAN_DISTRICT,region_name,strlen(region_name)+1);
|
||||
@@ -289,7 +289,7 @@ int test_expr_plus(Maat_feather_t feather,const char* table_name,scan_status_t*
|
||||
mid, 0);
|
||||
if(ret>0)
|
||||
{
|
||||
printf("Hit expr_puls rule %d.\n",result[0].config_id);
|
||||
printf("Hit expr_plus rule %d.\n",result[0].config_id);
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user