Issue in ngx_http_parse_request_line

akamatgi nginx-forum at nginx.us
Mon Dec 15 12:45:06 UTC 2014


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.
Regards,
-anirudh

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,255493,255493#msg-255493



More information about the nginx mailing list