From 5931b445ff16aa9e5bae94e06d844466224c0c0c Mon Sep 17 00:00:00 2001 From: zhengchao Date: Fri, 31 Jul 2020 19:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9group=5Fnum=E4=B8=BA?= =?UTF-8?q?0=E7=9A=84=E7=BC=96=E8=AF=91=E9=85=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_hierarchy.cpp | 11 +++++++++-- src/entry/Maat_rule.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/entry/Maat_hierarchy.cpp b/src/entry/Maat_hierarchy.cpp index b97f50f..7965a66 100644 --- a/src/entry/Maat_hierarchy.cpp +++ b/src/entry/Maat_hierarchy.cpp @@ -331,7 +331,7 @@ int Maat_hierarchy_compile_add(struct Maat_hierarchy* hier, int compile_id, int HASH_FIND_INT(hier->hash_compile_by_id, &compile_id, compile); if(!compile) { - assert(declared_clause_num>0); + assert(declared_clause_num>=0); compile=Maat_hierarchy_compile_new(hier, compile_id); compile->declared_clause_num=declared_clause_num; compile->user_data=user_data; @@ -791,7 +791,8 @@ static struct bool_matcher* Maat_hierarchy_build_bool_matcher(struct Maat_hierar j++; } } - if(j==compile->declared_clause_num) + //some compile may have zero groups, e.g. default policy. + if(j==compile->declared_clause_num&&j>0) { bool_expr_array[expr_cnt].user_tag=compile; bool_expr_array[expr_cnt].item_num=j; @@ -802,6 +803,12 @@ static struct bool_matcher* Maat_hierarchy_build_bool_matcher(struct Maat_hierar //Final STEP, build the bool matcher. size_t mem_size=0; + if(expr_cnt==0) + { + MESA_handle_runtime_log(hier->logger, RLOG_LV_FATAL, module_maat_hierarchy, + "No expr to build."); + return NULL; + } bm=bool_matcher_new(bool_expr_array, expr_cnt, hier->thread_num, &mem_size); if(bm!=NULL) { diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 6d829a3..0b6f481 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -34,7 +34,7 @@ #include "stream_fuzzy_hash.h" #include "gram_index_engine.h" -int MAAT_FRAME_VERSION_3_0_20200724=1; +int MAAT_FRAME_VERSION_3_0_20200731=1; int is_valid_table_name(const char* str) {