summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2020-07-02 20:22:38 +0800
committerzhengchao <[email protected]>2020-07-02 20:22:38 +0800
commit03e303f939ed89412f93347e9fa86439fb21a964 (patch)
tree6929b3f647a44c6276b242ca6488e6c97b5b0990
parent4cb3f13b14ca5663565017812d752a1548185fc1 (diff)
在对编译配置排序时,如果其已被删除,compile_sort_para_set会访问空指针,导致段错误。
-rw-r--r--src/entry/Maat_api.cpp25
-rw-r--r--src/entry/Maat_rule.cpp2
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_cnt<size; i++)
{
relation=relation_array[i];
@@ -486,9 +473,9 @@ int region_compile(_Maat_feather_t*feather, struct scan_hit_status *_mid, const
pthread_rwlock_unlock(&(relation->rwlock));
}
}
-
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)
{