From 03e303f939ed89412f93347e9fa86439fb21a964 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Thu, 2 Jul 2020 20:22:38 +0800 Subject: 在对编译配置排序时,如果其已被删除,compile_sort_para_set会访问空指针,导致段错误。 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_api.cpp | 25 ++++++------------------- src/entry/Maat_rule.cpp | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index b25867a..e0afd9f 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -142,17 +142,6 @@ static int compile_sort_para_compare(const struct compile_sort_para* a, const st } } -static int compare_compile_inner(const void *a, const void *b) -{ - const struct Maat_compile_group_relation *ra=*(const struct Maat_compile_group_relation **)a; - const struct Maat_compile_group_relation *rb=*(const struct Maat_compile_group_relation **)b; - - struct compile_sort_para sa, sb; - compile_sort_para_set(&sa, ra, NULL); - compile_sort_para_set(&sb, rb, NULL); - - return compile_sort_para_compare(&sa, &sb); -} static int compile_sort_para_compare_no_type(const void* a, const void* b) { return compile_sort_para_compare((const struct compile_sort_para*) a, (const struct compile_sort_para*) b); @@ -174,8 +163,11 @@ size_t Maat_rule_sort_by_evaluation_order(Maat_feather_t feather, struct Maat_ru p=(struct Maat_compile_group_relation *)HASH_fetch_by_id(_feather->scanner->compile_hash, rule_array[i].config_id); if(p && 0==pthread_rwlock_tryrdlock(&(p->rwlock)))//rule maybe already deleted. { - compile_sort_para_set(sort_para+i, p, copy_rule_array+i); - j++; + if(p->compile) + { + compile_sort_para_set(sort_para+i, p, copy_rule_array+i); + j++; + } pthread_rwlock_unlock(&(p->rwlock)); } } @@ -450,11 +442,6 @@ int region_compile(_Maat_feather_t*feather, struct scan_hit_status *_mid, const { scan_ret=0; } - if(scan_ret>1) - { - qsort(relation_array, scan_ret, sizeof(struct Maat_compile_group_relation*), - compare_compile_inner); - } for(i=0; i<(unsigned int)scan_ret&&result_cntrwlock)); } } - if(result_cnt>0) { + Maat_rule_sort_by_evaluation_order((Maat_feather_t)feather, result, result_cnt); alignment_int64_array_add(feather->hit_cnt, thread_num, 1); } if(region_hit_num==0&&result_cnt>0) diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index e7530d1..989e3ad 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -33,7 +33,7 @@ #include "stream_fuzzy_hash.h" #include "gram_index_engine.h" -int MAAT_FRAME_VERSION_2_9_20200622=1; +int MAAT_FRAME_VERSION_2_9_20200702=1; int is_valid_table_name(const char* str) { -- cgit v1.2.3