bugfix:修复HTTP请求中没有HOST时,未判空导致coredump

This commit is contained in:
fengweihao
2023-05-31 19:16:21 +08:00
parent 5af89ccc93
commit 6574566276
2 changed files with 10 additions and 5 deletions

View File

@@ -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;