httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47177] mod_proxy rewrites incorrectly IPv6 literal addresses
Date Mon, 11 May 2009 07:17:45 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47177





--- Comment #3 from Carlos Garcia Braschi <cgbraschi@gmail.com>  2009-05-11 00:17:43
PST ---
mod_proxy_http.c

A naive and untested fix (I'm sorry, but I don't have a developer environment
to test it), borrowing from the proxy_http_canon function, would be to change
function ap_proxy_http_request in this way. 

from:
    if (conf->preserve_host == 0) {
        if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
            buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", uri->port_str,
                              CRLF, NULL);
        } else {
            buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
        }
    }

to 
    if (conf->preserve_host == 0) {
        if (ap_strchr_c(uri->hostname, ':')) { /* if literal IPv6 address */
            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]:", 
                                  uri->port_str, CRLF, NULL);
            } else {
                buf = apr_pstrcat(p, "Host: [", uri->hostname, "]", CRLF,
NULL);
            }
        } else {
            if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
                buf = apr_pstrcat(p, "Host: ", uri->hostname, ":", 
                                  uri->port_str, CRLF, NULL);
            } else {
                buf = apr_pstrcat(p, "Host: ", uri->hostname, CRLF, NULL);
            }
        }
    }

I'm not sure if a more architectural fix having apr_uri_parse function leaving
the brackets for IPv6 hostnames would be better, as they are always required to
be there in URIs... but that means apr_uri and all of the code depending on
apr_uri to be fixed....

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message