From e62a5132ca6ab74f324bf46fe91ee89e1951578c Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 8 Dec 2020 01:43:36 +0300 Subject: SSL: fixed SSL shutdown on lingering close. Ensure c->recv is properly reset to ngx_recv if SSL_shutdown() blocks on writing. The bug had appeared in 554c6ae25ffc. --- src/http/ngx_http_request.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/http/ngx_http_request.c') diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 12a68a961..e954c7c25 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -3397,8 +3397,6 @@ ngx_http_set_lingering_close(ngx_connection_t *c) c->ssl->handler = ngx_http_set_lingering_close; return; } - - c->recv = ngx_recv; } #endif -- cgit v1.2.3 From ce9971b2b5c14982afede89635508334938ac520 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Thu, 10 Dec 2020 20:09:30 +0300 Subject: Fixed parsing of absolute URIs with empty path (ticket #2079). When the request line contains request-target in the absolute-URI form, it can contain path-empty instead of a single slash (see RFC 7230, RFC 3986). Previously, the ngx_http_parse_request_line() function only accepted empty path when there was no query string. With this change, non-empty query is also correctly handled. That is, request line "GET http://example.com?foo HTTP/1.1" is accepted and results in $uri "/" and $args "foo". Note that $request_uri remains "?foo", similarly to how spaces in URIs are handled. Providing "/?foo", similarly to how "/" is provided for "GET http://example.com HTTP/1.1", requires allocation. --- src/http/ngx_http_request.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/http/ngx_http_request.c') diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index e954c7c25..73ab204a2 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1224,7 +1224,11 @@ ngx_http_process_request_uri(ngx_http_request_t *r) r->uri.len = r->uri_end - r->uri_start; } - if (r->complex_uri || r->quoted_uri) { + if (r->complex_uri || r->quoted_uri || r->empty_path_in_uri) { + + if (r->empty_path_in_uri) { + r->uri.len++; + } r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1); if (r->uri.data == NULL) { @@ -1250,7 +1254,7 @@ ngx_http_process_request_uri(ngx_http_request_t *r) r->unparsed_uri.len = r->uri_end - r->uri_start; r->unparsed_uri.data = r->uri_start; - r->valid_unparsed_uri = r->space_in_uri ? 0 : 1; + r->valid_unparsed_uri = (r->space_in_uri || r->empty_path_in_uri) ? 0 : 1; if (r->uri_ext) { if (r->args_start) { -- cgit v1.2.3 From 2e94c81b0bf1d8e695d9afd074c79520aa03081a Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Thu, 10 Dec 2020 20:09:39 +0300 Subject: Removed extra allocation for r->uri. The ngx_http_parse_complex_uri() function cannot make URI longer and does not null-terminate URI, so there is no need to allocate an extra byte. This allocation appears to be a leftover from changes in 461:a88a3e4e158f (0.1.5), where null-termination of r->uri and many other strings was removed. --- src/http/ngx_http_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/http/ngx_http_request.c') diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 73ab204a2..d453b8a49 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1230,7 +1230,7 @@ ngx_http_process_request_uri(ngx_http_request_t *r) r->uri.len++; } - r->uri.data = ngx_pnalloc(r->pool, r->uri.len + 1); + r->uri.data = ngx_pnalloc(r->pool, r->uri.len); if (r->uri.data == NULL) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); return NGX_ERROR; -- cgit v1.2.3