From c8c7beb96f61e2251abbc345357116131cf91c22 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Mon, 29 Sep 2025 20:47:27 +0400 Subject: Added $request_port and $is_request_port variables. The $request_port variable contains the port passed by the client in the request line (for HTTP/1.x) or ":authority" pseudo-header (for HTTP/2 and HTTP/3). If the request line contains no host, or ":authority" is missing, then $request_port is taken from the "Host" header, similar to the $host variable. The $is_request_port variable contains ":" if $request_port is non-empty, and is empty otherwise. --- src/http/ngx_http_parse.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/http/ngx_http_parse.c') diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index a45c04554..68f604e10 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -446,6 +446,11 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) case sw_port: if (ch >= '0' && ch <= '9') { + if (r->port >= 6553 && (r->port > 6553 || (ch - '0') > 5)) { + return NGX_HTTP_PARSE_INVALID_REQUEST; + } + + r->port = r->port * 10 + (ch - '0'); break; } -- cgit