释放pme后,未将流标签置空,新的数据包获取pme时得到非法地址空间导致段错误
修复内存泄漏的问题
This commit is contained in:
@@ -93,15 +93,10 @@ id2field_t g_tsg_proto_name2id[PROTO_MAX]={{PROTO_UNKONWN, 0, "unknown"},
|
||||
|
||||
|
||||
static int init_context(void **pme, int thread_seq)
|
||||
{
|
||||
struct master_context *context=(struct master_context *)*pme;
|
||||
|
||||
{
|
||||
*pme=dictator_malloc(thread_seq, sizeof(struct master_context));
|
||||
memset(*pme, 0, sizeof(struct master_context));
|
||||
context=(struct master_context *)*pme;
|
||||
|
||||
context->continue_scan_proto_id=APP_SCAN_FLAG_CONTINUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -357,6 +352,8 @@ static int tsg_proto_name2flag(char *proto_list, int *flag)
|
||||
|
||||
static void free_context_label(int thread_seq, void *project_req_value)
|
||||
{
|
||||
project_req_value=NULL;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -1103,6 +1100,7 @@ int scan_application_id_and_properties(const struct streaminfo *a_stream, struct
|
||||
hit_num+=tsg_scan_app_properties_policy(g_tsg_maat_feather, a_stream, result+hit_num, result_num-hit_num, mid, dict->characteristics, (char *)"characteristics", thread_seq);
|
||||
|
||||
hit_num+=tsg_scan_app_id_policy(g_tsg_maat_feather, a_stream, result+hit_num, result_num-hit_num, mid, dict->app_name, identify_result->app_id[i], thread_seq);
|
||||
app_id_dict_free_data(g_tsg_para.table_id[TABLE_APP_ID_DICT], (MAAT_PLUGIN_EX_DATA *)&dict, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1205,13 +1203,13 @@ static int app_identify_result_cb(const struct streaminfo *a_stream, int bridge_
|
||||
context=(struct master_context *)get_struct_project(a_stream, g_tsg_para.context_project_id);
|
||||
if(context==NULL)
|
||||
{
|
||||
init_context((void **)&context, a_stream->threadnum);
|
||||
init_context((void **)(&context), a_stream->threadnum);
|
||||
set_struct_project(a_stream, g_tsg_para.context_project_id, (void *)context);
|
||||
}
|
||||
|
||||
record_time_start(&context->last_scan_time);
|
||||
record_time_start(&(context->last_scan_time));
|
||||
|
||||
hit_num=scan_application_id_and_properties((struct streaminfo *)a_stream, scan_result, MAX_RESULT_NUM, &context->mid, identify_result, a_stream->threadnum);
|
||||
hit_num=scan_application_id_and_properties((struct streaminfo *)a_stream, scan_result, MAX_RESULT_NUM, &(context->mid), identify_result, a_stream->threadnum);
|
||||
master_deal_scan_result(a_stream, context, scan_result, hit_num, NULL);
|
||||
|
||||
return 0;
|
||||
@@ -1234,10 +1232,6 @@ static int master_deal_pending_state(const struct streaminfo *a_stream, struct m
|
||||
{
|
||||
set_session_attribute_label(a_stream, TSG_ATTRIBUTE_TYPE_JA3_HASH, NULL, a_stream->threadnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
context->continue_scan_proto_id=APP_SCAN_FLAG_STOP;
|
||||
}
|
||||
|
||||
table_id=get_table_id(context->proto);
|
||||
hit_num+=tsg_scan_shared_policy(g_tsg_maat_feather, a_stream, context->domain, result+hit_num, MAX_RESULT_NUM-hit_num, &context->mid, table_id, a_stream->threadnum);
|
||||
@@ -1340,6 +1334,7 @@ static unsigned char tsg_master_entry(const struct streaminfo *a_stream, void **
|
||||
{
|
||||
close_stream_free_context(a_stream, context, thread_seq);
|
||||
*pme=NULL;
|
||||
set_struct_project(a_stream, g_tsg_para.context_project_id, NULL); //
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
@@ -121,13 +121,10 @@ struct master_context
|
||||
{
|
||||
tsg_protocol_t proto;
|
||||
int hit_cnt;
|
||||
int app_id;
|
||||
int is_esni;
|
||||
char continue_scan_proto_id;
|
||||
unsigned short basic_proto_id;
|
||||
char *domain;
|
||||
struct Maat_rule_t *result;
|
||||
scan_status_t mid;
|
||||
struct Maat_rule_t *result;
|
||||
struct timespec last_scan_time;
|
||||
};
|
||||
|
||||
@@ -253,6 +250,7 @@ int tsg_statistic_init(const char *conffile, void *logger);
|
||||
void location_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
|
||||
void ASN_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
|
||||
void subscribe_id_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
|
||||
void app_id_dict_free_data(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void* argp);
|
||||
void security_compile_free(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||
struct Maat_rule_t *tsg_policy_decision_criteria(struct streaminfo *a_stream, Maat_rule_t *result, int result_num, int thread_seq);
|
||||
int tsg_scan_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream, tsg_protocol_t proto, scan_status_t *mid, Maat_rule_t*result, int result_num);
|
||||
|
||||
@@ -543,6 +543,9 @@ void security_compile_new(int idx, const struct Maat_rule_t* rule, const char* s
|
||||
{
|
||||
user_region->html_profile=item->valueint;
|
||||
}
|
||||
|
||||
cJSON_Delete(object);
|
||||
object=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1501,10 +1504,20 @@ int tsg_scan_app_properties_policy(Maat_feather_t maat_feather, const struct str
|
||||
if(property!=NULL && property_len>0 && district_len>0)
|
||||
{
|
||||
Maat_set_scan_status(g_tsg_maat_feather, mid, MAAT_SET_SCAN_DISTRICT, (void *)district, district_len);
|
||||
ret=Maat_full_scan_string(g_tsg_maat_feather, g_tsg_para.table_id[TABLE_SELECTOR_PROPERTIES], CHARSET_UTF8, property, property_len, property_result, NULL, MAX_RESULT_NUM,mid,thread_seq);
|
||||
ret=Maat_full_scan_string(g_tsg_maat_feather,
|
||||
g_tsg_para.table_id[TABLE_SELECTOR_PROPERTIES],
|
||||
CHARSET_UTF8,
|
||||
property,
|
||||
property_len,
|
||||
property_result,
|
||||
NULL,
|
||||
MAX_RESULT_NUM,
|
||||
mid,
|
||||
thread_seq
|
||||
);
|
||||
for(i=0; i<ret; i++)
|
||||
{
|
||||
ret2=Maat_scan_intval(g_tsg_maat_feather, g_tsg_para.table_id[TABLE_SELECTOR_ID], property_result[i].config_id, result, result_num, mid, thread_seq);
|
||||
ret2=Maat_scan_intval(g_tsg_maat_feather, g_tsg_para.table_id[TABLE_SELECTOR_ID], property_result[i].config_id, result+hit_num, result_num-hit_num, mid, thread_seq);
|
||||
if(ret2>0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_tsg_para.logger,
|
||||
@@ -1513,9 +1526,9 @@ int tsg_scan_app_properties_policy(Maat_feather_t maat_feather, const struct str
|
||||
"Hit selector_id: %d ret: %d policy_id: %d service: %d action: %d addr: %s",
|
||||
property_result[i].config_id,
|
||||
ret2,
|
||||
result[0].config_id,
|
||||
result[0].service_id,
|
||||
result[0].action,
|
||||
result[hit_num].config_id,
|
||||
result[hit_num].service_id,
|
||||
result[hit_num].action,
|
||||
PRINTADDR(a_stream, g_tsg_para.level)
|
||||
);
|
||||
|
||||
|
||||
@@ -1058,7 +1058,8 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
|
||||
rdkafka_conf = rd_kafka_conf_new();
|
||||
rd_kafka_conf_set(rdkafka_conf, "queue.buffering.max.messages", _instance->send_queue_max_msg, kafka_errstr, sizeof(kafka_errstr));
|
||||
rd_kafka_conf_set(rdkafka_conf, "topic.metadata.refresh.interval.ms", _instance->refresh_interval_ms, kafka_errstr, sizeof(kafka_errstr));
|
||||
rd_kafka_conf_set(rdkafka_conf, "request.required.acks", _instance->require_ack, kafka_errstr, sizeof(kafka_errstr));
|
||||
rd_kafka_conf_set(rdkafka_conf, "request.required.acks", _instance->require_ack, kafka_errstr, sizeof(kafka_errstr));
|
||||
rd_kafka_conf_set(rdkafka_conf, "socket.keepalive.enable", "true", kafka_errstr, sizeof(kafka_errstr));
|
||||
|
||||
if(!(kafka_handle=rd_kafka_new(RD_KAFKA_PRODUCER, rdkafka_conf, kafka_errstr, sizeof(kafka_errstr))))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user