# HG changeset patch # User Igor Sysoev # Date 1166178297 0 # Node ID a6fe6bedb9e312c332dd149e8f790bedcc000f91 # Parent 4f3d57408877c909541eee3074c701a5ba5d2843 fix segfault when $host is used and *) request is "GET http://host" without CR or LF, or timed out *) request is "GET http://host" with a large blank space diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1104,7 +1104,9 @@ ngx_http_alloc_large_header_buffer(ngx_h if (r->host_start) { r->host_start = new + (r->host_start - old); - r->host_end = new + (r->host_end - old); + if (r->host_end) { + r->host_end = new + (r->host_end - old); + } } if (r->port_start) { diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -678,9 +678,13 @@ ngx_http_variable_host(ngx_http_request_ v->data = r->server_name.data; } - } else { + } else if (r->host_end) { v->len = r->host_end - r->host_start; v->data = r->host_start; + + } else { + v->not_found = 1; + return NGX_OK; } v->valid = 1;