Issue in ngx_http_parse_request_line

Valentin V. Bartenev vbart at nginx.com
Mon Dec 15 13:01:50 UTC 2014


On Monday 15 December 2014 07:45:06 akamatgi wrote:
> Hi,
> I can see an issue in assigning the port_start and port_end members of
> ngx_http_request_t inside ngx_http_parse_request_line().
> If the request line has a absolute URI with explicit port specified, then
> port_end is set correctly inside ngx_http_parse_request_line():
> ...
> case sw_port:
>             if (ch >= '0' && ch <= '9') {
>                 break;
>             }
> 
>             switch (ch) {
>             case '/':
>                 r->port_end = p;
>                 r->uri_start = p;
>                 state = sw_after_slash_in_uri;
>                 break;
> ...
> 
> However, r->port_start is still 0.
> I think the following code should be modified:
> ...
> case sw_host_end:
> 
>             r->host_end = p;
> 
>             switch (ch) {
>             case ':':
> +               r->port_start = (p + 1);
>                 state = sw_port;
>                 break;
> ...
> 
> Let me know if it sounds OK.

While it may be the right change, please note that r->port_start
and r->port_end aren't used anywhere and they are just a dead code.

  wbr, Valentin V. Bartenev



More information about the nginx mailing list