Skip to content

Commit 0751293

Browse files
author
Felipe Zimmerle
committed
Small fix on the top of #950 to sanity check the variable before use it
1 parent cdde120 commit 0751293

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ ngx_http_modsecurity_load_request(ngx_http_request_t *r)
364364
/* &r->headers_in.user); */
365365
req->parsed_uri.fragment = (char *)ngx_pstrdup0(r->pool, &r->exten);
366366

367-
req->hostname = (char *)ngx_pstrdup0(r->pool, &r->headers_in.server);
367+
if (&r->headers_in != NULL && &r->headers_in.server != NULL) {
368+
req->hostname = (char *)ngx_pstrdup0(r->pool, &r->headers_in.server);
369+
} else {
370+
req->hostname = (char *)ngx_pstrdup0(r->pool,
371+
(ngx_str_t *)&ngx_cycle->hostname);
372+
}
368373

369374
if (r->header_only) {
370375
req->header_only = r->header_only;

0 commit comments

Comments
 (0)