From: Jim Jagielski Date: Mon, 17 Nov 2003 17:14:53 +0000 (+0000) Subject: Make UseCanonicalName off correctly grab port info from X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5f2312f25e82fbbf5481e551c3d521cacb0257b;p=thirdparty%2Fapache%2Fhttpd.git Make UseCanonicalName off correctly grab port info from the client. Make UseCanonicalName socket port aware. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@101803 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index f1240f5ca27..7620e1089b4 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 1.3.30 + *) UseCanonicalName off was ignoring the client provided + port information. [Jim Jagielski] + Changes with Apache 1.3.29 *) SECURITY: CAN-2003-0542 (cve.mitre.org) diff --git a/src/main/http_core.c b/src/main/http_core.c index 0896698be84..ee496314a1a 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -826,16 +826,27 @@ API_EXPORT(const char *) ap_get_server_name(request_rec *r) API_EXPORT(unsigned) ap_get_server_port(const request_rec *r) { unsigned port; + unsigned cport = ntohs(r->connection->local_addr.sin_port); core_dir_config *d = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); - port = r->server->port ? r->server->port : ap_default_port(r); - if (d->use_canonical_name == USE_CANONICAL_NAME_OFF - || d->use_canonical_name == USE_CANONICAL_NAME_DNS) { - return r->hostname ? ntohs(r->connection->local_addr.sin_port) - : port; + || d->use_canonical_name == USE_CANONICAL_NAME_DNS) { + + /* With UseCanonicalName Off Apache will form self-referential + * URLs using the hostname and port supplied by the client if + * any are supplied (otherwise it will use the canonical name). + */ + port = r->parsed_uri.port_str ? r->parsed_uri.port : + cport ? cport : + r->server->port ? r->server->port : + ap_default_port(r); + } else { /* d->use_canonical_name == USE_CANONICAL_NAME_ON */ + port = r->server->port ? r->server->port : + cport ? cport : + ap_default_port(r); } + /* default */ return port; }