From 169e918a64119a2560907b2527e1a36bbdd5d59f Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Thu, 10 Dec 2015 14:40:32 -0300 Subject: [PATCH] Small fix on the top of #950 to sanity check the variable before use it --- nginx/modsecurity/ngx_http_modsecurity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nginx/modsecurity/ngx_http_modsecurity.c b/nginx/modsecurity/ngx_http_modsecurity.c index 75ab9467..2f99ab4b 100644 --- a/nginx/modsecurity/ngx_http_modsecurity.c +++ b/nginx/modsecurity/ngx_http_modsecurity.c @@ -363,7 +363,12 @@ ngx_http_modsecurity_load_request(ngx_http_request_t *r) /* &r->headers_in.user); */ req->parsed_uri.fragment = (char *)ngx_pstrdup0(r->pool, &r->exten); - req->hostname = (char *)ngx_pstrdup0(r->pool, &r->headers_in.server); + if (&r->headers_in != NULL && &r->headers_in.server != NULL) { + req->hostname = (char *)ngx_pstrdup0(r->pool, &r->headers_in.server); + } else { + req->hostname = (char *)ngx_pstrdup0(r->pool, + (ngx_str_t *)&ngx_cycle->hostname); + } if (r->header_only) { req->header_only = r->header_only;