From 6b42c711b3ea5d0a4cd9b6e18314ea0d61fa24ef Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 24 Dec 2018 20:23:48 +0600 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8Maat=5Fhelper=5Fread=5Fcolumn?= =?UTF-8?q?=E9=87=8D=E6=9E=84accept=20tag=E8=AF=BB=E5=8F=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_rule.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index cc688da..9d5fcd5 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -3178,19 +3178,25 @@ void update_plugin_table(struct Maat_table_desc* table,const char* table_line,_M char *p=NULL; char* copy=NULL; size_t is_valid_offset=0, valid_len=0; - char *token=NULL,*sub_token=NULL,*saveptr; + size_t accept_tag_offset=0, accept_tag_len=0; if(plugin_desc->rule_tag_column>0&&n_tags>0) { - copy=_maat_strdup(table_line); - for (token = copy, i=0; irule_tag_column ; token= NULL, i++) + ret=Maat_helper_read_column(table_line, plugin_desc->rule_tag_column, &accept_tag_offset, &accept_tag_len); + if(ret<0) { - sub_token= strtok_r(token," \t", &saveptr); - if (sub_token == NULL) - break; + MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module , + "update error, could not locate tag in column %d of plugin table %s:%s", + plugin_desc->rule_tag_column, + table->table_name[table->updating_name], + table_line); + table->udpate_err_cnt++; + return; } - if(i==plugin_desc->rule_tag_column&&strlen(sub_token)>2) + if(accept_tag_len>2) { - ret=compare_accept_tag(sub_token, tags, n_tags); + copy=ALLOC(char, accept_tag_len+1); + memcpy(copy, table_line+accept_tag_offset, accept_tag_len); + ret=compare_accept_tag(copy, tags, n_tags); if(ret<0) { MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_module , @@ -3202,9 +3208,9 @@ void update_plugin_table(struct Maat_table_desc* table,const char* table_line,_M { table->unmatch_tag_cnt++; } + free(copy); + copy=NULL; } - free(copy); - copy=NULL; if(ret!=1) { return; @@ -3217,7 +3223,7 @@ void update_plugin_table(struct Maat_table_desc* table,const char* table_line,_M if(plugin_desc->have_exdata) { - ret=get_column_pos(table_line, plugin_desc->valid_flag_column, &is_valid_offset, &valid_len); + ret=Maat_helper_read_column(table_line, plugin_desc->valid_flag_column, &is_valid_offset, &valid_len); pthread_rwlock_wrlock(&(table_rt->plugin.rwlock)); if(atoi(table_line+is_valid_offset)==1)