summaryrefslogtreecommitdiff
path: root/plugin/protocol/http/src/http_half.cpp
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2023-05-31 19:16:21 +0800
committerfengweihao <[email protected]>2023-05-31 19:16:21 +0800
commit657456627667239d2ee1b0983fbe7f46cd577032 (patch)
treecd66f63c45604e7ce3efc1103d0059975328457c /plugin/protocol/http/src/http_half.cpp
parent5af89ccc936892fe4ddf84ec72e4a83d47579e98 (diff)
bugfix:修复HTTP请求中没有HOST时,未判空导致coredump
Diffstat (limited to 'plugin/protocol/http/src/http_half.cpp')
-rw-r--r--plugin/protocol/http/src/http_half.cpp9
1 files changed, 7 insertions, 2 deletions
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;