diff options
author | Eric Covener <covener@apache.org> | 2010-12-28 12:21:56 +0100 |
---|---|---|
committer | Eric Covener <covener@apache.org> | 2010-12-28 12:21:56 +0100 |
commit | 53e4a906db22ae4aef754973d6eb35993edd30b5 (patch) | |
tree | a702b0de260f0aee5f84664eb3bc3273cca7aec9 /server/vhost.c | |
parent | Doc for r1053230, NameVirtualHost is now unnecessary and other general NVH-vs... (diff) | |
download | apache2-53e4a906db22ae4aef754973d6eb35993edd30b5.tar.xz apache2-53e4a906db22ae4aef754973d6eb35993edd30b5.zip |
prefer exact port matches in ip-based VH lookup over wildcards.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1053309 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/vhost.c')
-rw-r--r-- | server/vhost.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/server/vhost.c b/server/vhost.c index 02e24405bf..7763eddd5f 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -376,7 +376,8 @@ static name_chain *new_name_chain(apr_pool_t *p, static APR_INLINE ipaddr_chain *find_ipaddr(apr_sockaddr_t *sa) { unsigned bucket; - ipaddr_chain *trav; + ipaddr_chain *trav = NULL; + ipaddr_chain *wild_match = NULL; /* scan the hash table for an exact match first */ bucket = hash_addr(sa); @@ -384,28 +385,39 @@ static APR_INLINE ipaddr_chain *find_ipaddr(apr_sockaddr_t *sa) server_addr_rec *sar = trav->sar; apr_sockaddr_t *cur = sar->host_addr; - if (cur->port == 0 || sa->port == 0 || cur->port == sa->port) { + if (cur->port == sa->port) { if (apr_sockaddr_equal(cur, sa)) { return trav; } } + if (wild_match == NULL && (cur->port == 0 || sa->port == 0)) { + if (apr_sockaddr_equal(cur, sa)) { + /* don't break, continue looking for an exact match */ + wild_match = trav; + } + } } - return NULL; + return wild_match; } static ipaddr_chain *find_default_server(apr_port_t port) { server_addr_rec *sar; - ipaddr_chain *trav; + ipaddr_chain *trav = NULL; + ipaddr_chain *wild_match = NULL; for (trav = default_list; trav; trav = trav->next) { sar = trav->sar; - if (sar->host_port == 0 || sar->host_port == port) { + if (sar->host_port == port) { /* match! */ return trav; } + if (wild_match == NULL && sar->host_port == 0) { + /* don't break, continue looking for an exact match */ + wild_match = trav; + } } - return NULL; + return wild_match; } static void dump_a_vhost(apr_file_t *f, ipaddr_chain *ic) |