region_rule_inner中增加magic_num,以诊断region配置删除时可能发生的野指针访问;同时hierarchy增加对region_id查找的判空,以避免在一个region扫描命中后,hierarchy中该region又被删除,产生的空指针访问。
This commit is contained in:
@@ -235,6 +235,7 @@ int region_compile(_Maat_feather_t*feather, struct Maat_hierarchy_compile_mid* c
|
|||||||
for(i=0; (size_t)i<region_hit_num;i++)
|
for(i=0; (size_t)i<region_hit_num;i++)
|
||||||
{
|
{
|
||||||
region=*(struct Maat_region_inner**)((char*)region_hit+region_type_size*i+user_data_offset);
|
region=*(struct Maat_region_inner**)((char*)region_hit+region_type_size*i+user_data_offset);
|
||||||
|
assert(region->magic_num==REGION_RULE_MAGIC);
|
||||||
if(region_hit_wraper->virtual_table_ids)
|
if(region_hit_wraper->virtual_table_ids)
|
||||||
{
|
{
|
||||||
virtual_table_id=region_hit_wraper->virtual_table_ids[i];
|
virtual_table_id=region_hit_wraper->virtual_table_ids[i];
|
||||||
|
|||||||
@@ -1052,6 +1052,12 @@ void Maat_hierarchy_compile_mid_udpate(struct Maat_hierarchy_compile_mid* mid, i
|
|||||||
mid->this_scan_region_hit_cnt++;
|
mid->this_scan_region_hit_cnt++;
|
||||||
pthread_rwlock_rdlock(&hier->rwlock);
|
pthread_rwlock_rdlock(&hier->rwlock);
|
||||||
HASH_FIND_INT(hier->hash_region_by_id, ®ion_id, region);
|
HASH_FIND_INT(hier->hash_region_by_id, ®ion_id, region);
|
||||||
|
if(!region)
|
||||||
|
{
|
||||||
|
pthread_rwlock_unlock(&hier->rwlock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
group=region->ref_parent_group;
|
group=region->ref_parent_group;
|
||||||
|
|
||||||
if(group->top_group_cnt==0)
|
if(group->top_group_cnt==0)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#include "stream_fuzzy_hash.h"
|
#include "stream_fuzzy_hash.h"
|
||||||
#include "gram_index_engine.h"
|
#include "gram_index_engine.h"
|
||||||
|
|
||||||
int MAAT_FRAME_VERSION_3_0_20200703=1;
|
int MAAT_FRAME_VERSION_3_0_20200706=1;
|
||||||
|
|
||||||
int is_valid_table_name(const char* str)
|
int is_valid_table_name(const char* str)
|
||||||
{
|
{
|
||||||
@@ -715,6 +715,8 @@ void op_expr_add_rule(struct op_expr_t* op_expr,scan_rule_t* p_rule)
|
|||||||
}
|
}
|
||||||
void Maat_region_inner_free(struct Maat_region_inner* region)
|
void Maat_region_inner_free(struct Maat_region_inner* region)
|
||||||
{
|
{
|
||||||
|
assert(region->magic_num==REGION_RULE_MAGIC);
|
||||||
|
region->magic_num=0;
|
||||||
free(region);
|
free(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,6 +1033,7 @@ int get_district_id(Maat_scanner *scanner,const char* district_str)
|
|||||||
struct Maat_region_inner* Maat_region_inner_new(int group_id, int region_id, int table_id, int district_id)
|
struct Maat_region_inner* Maat_region_inner_new(int group_id, int region_id, int table_id, int district_id)
|
||||||
{
|
{
|
||||||
struct Maat_region_inner* region=ALLOC(struct Maat_region_inner, 1);
|
struct Maat_region_inner* region=ALLOC(struct Maat_region_inner, 1);
|
||||||
|
region->magic_num=REGION_RULE_MAGIC;
|
||||||
region->region_id=region_id;
|
region->region_id=region_id;
|
||||||
region->group_id=group_id;
|
region->group_id=group_id;
|
||||||
region->table_id=table_id;
|
region->table_id=table_id;
|
||||||
|
|||||||
@@ -136,9 +136,10 @@ struct op_expr_t
|
|||||||
int table_id;
|
int table_id;
|
||||||
int rule_type;
|
int rule_type;
|
||||||
};
|
};
|
||||||
|
#define REGION_RULE_MAGIC 0x4d3c2b1a
|
||||||
struct Maat_region_inner
|
struct Maat_region_inner
|
||||||
{
|
{
|
||||||
|
long long magic_num;
|
||||||
int region_id;
|
int region_id;
|
||||||
int group_id;
|
int group_id;
|
||||||
int district_id;
|
int district_id;
|
||||||
|
|||||||
Reference in New Issue
Block a user