From 069b7d9fb20f8545eeebd2a85a4fd93a6e8d0c75 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Fri, 18 Jul 2014 20:02:11 +0400 Subject: [PATCH] Reset of r->uri.len on URI parsing errors. This ensures that debug logging and the $uri variable (if used in 400 Bad Request processing) will not try to access uninitialized memory. Found by Sergey Bobrov. --- src/http/ngx_http_request.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 4bf9d1fcf..845ada322 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1071,6 +1071,8 @@ ngx_http_process_request_uri(ngx_http_request_t *r) cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); if (ngx_http_parse_complex_uri(r, cscf->merge_slashes) != NGX_OK) { + r->uri.len = 0; + ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "client sent invalid request"); ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);