From 657456627667239d2ee1b0983fbe7f46cd577032 Mon Sep 17 00:00:00 2001 From: fengweihao Date: Wed, 31 May 2023 19:16:21 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=E4=BF=AE=E5=A4=8DHTTP=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E4=B8=AD=E6=B2=A1=E6=9C=89HOST=E6=97=B6=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E5=88=A4=E7=A9=BA=E5=AF=BC=E8=87=B4coredump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/tsg-http/src/tsg_http.cpp | 6 +++--- plugin/protocol/http/src/http_half.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp index 5258daa..954ed23 100644 --- a/plugin/business/tsg-http/src/tsg_http.cpp +++ b/plugin/business/tsg-http/src/tsg_http.cpp @@ -772,7 +772,7 @@ void policy_action_param_dup(int idx, void **to, void **from, long argl, void *a void ma_profile_table_new_cb(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp) { int ret=0, profile_id=0, is_valid=0; - char profile_name[128]={0}, formate[128]={0}; + char profile_name[256]={0}, formate[128]={0}; char profile_path[TFE_PATH_MAX]={0}; ret=sscanf(table_line, "%d\t%s\t%s\t%s\t%d", &profile_id, profile_name, formate, profile_path, &is_valid); @@ -812,7 +812,7 @@ void ma_profile_table_new_cb(const char *table_name, int table_id, const char* k void ma_insert_profile_table_new_cb(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp) { int ret=0, profile_id=0, is_valid=0; - char profile_name[128]={0}, formate[128]={0}; + char profile_name[256]={0}, formate[128]={0}; char profile_path[TFE_PATH_MAX]={0},profile_position[TFE_PATH_MAX]={0}; ret=sscanf(table_line, "%d\t%s\t%s\t%s\t%s\t%d", &profile_id, profile_name, formate, profile_path, profile_position, &is_valid); @@ -852,7 +852,7 @@ void ma_insert_profile_table_new_cb(const char *table_name, int table_id, const void ma_hijack_profile_table_new_cb(const char *table_name, int table_id, const char* key, const char* table_line, void **ad, long argl, void* argp) { int ret=0, profile_id=0, is_valid=0; - char profile_name[128]={0}, formate[128]={0}; + char profile_name[256]={0}, formate[128]={0}; char profile_path[TFE_PATH_MAX]={0},hijack_name[128]={0}; ret=sscanf(table_line, "%d\t%s\t%s\t%s\t%s\t%d", &profile_id, profile_name, hijack_name, formate, profile_path, &is_valid); diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp index 07bfa1a..3d832b4 100644 --- a/plugin/protocol/http/src/http_half.cpp +++ b/plugin/protocol/http/src/http_half.cpp @@ -152,8 +152,13 @@ void __hf_public_req_fill_from_private(struct http_half_private * hf_private, st hf_private->method_or_status = (enum tfe_http_std_method) parser->method; const static struct http_field_name __host_field_name = {TFE_HTTP_HOST, NULL}; - hf_private->host = strdup((char *) tfe_http_field_read(hf_public, &__host_field_name)); - hf_req_spec->host = hf_private->host; + + char *host= (char *)tfe_http_field_read(hf_public, &__host_field_name); + if(host) + { + hf_private->host = strdup(host); + hf_req_spec->host = hf_private->host; + } /* uri is stored in underlay evbuffer, we need to append a terminal zero */ static const char __zero = 0;