Skip to content

Commit 36465e9

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

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

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

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

0 commit comments

Comments
 (0)