Blame SOURCES/httpd-2.4.6-r1528958.patch

0943f8
--- a/server/vhost.c	2013/07/15 11:50:50	1503188
0943f8
+++ b/server/vhost.c	2013/10/03 18:31:22	1528958
0943f8
@@ -577,14 +577,22 @@
0943f8
      */
0943f8
 
0943f8
     for (s = main_s->next; s; s = s->next) {
0943f8
+        server_addr_rec *sar_prev = NULL;
0943f8
         has_default_vhost_addr = 0;
0943f8
         for (sar = s->addrs; sar; sar = sar->next) {
0943f8
             ipaddr_chain *ic;
0943f8
             char inaddr_any[16] = {0}; /* big enough to handle IPv4 or IPv6 */
0943f8
-
0943f8
+            /* XXX: this treats 0.0.0.0 as a "default" server which matches no-exact-match for IPv6 */
0943f8
             if (!memcmp(sar->host_addr->ipaddr_ptr, inaddr_any, sar->host_addr->ipaddr_len)) {
0943f8
                 ic = find_default_server(sar->host_port);
0943f8
-                if (!ic || sar->host_port != ic->sar->host_port) {
0943f8
+
0943f8
+                if (ic && sar->host_port == ic->sar->host_port) { /* we're a match for an existing "default server"  */
0943f8
+                    if (!sar_prev || memcmp(sar_prev->host_addr->ipaddr_ptr, inaddr_any, sar_prev->host_addr->ipaddr_len)
0943f8
+                                  || sar_prev->host_port != sar->host_port) { 
0943f8
+                        add_name_vhost_config(p, main_s, s, sar, ic);
0943f8
+                    }
0943f8
+                }
0943f8
+                else { 
0943f8
                     /* No default server, or we found a default server but
0943f8
                     ** exactly one of us is a wildcard port, which means we want
0943f8
                     ** two ip-based vhosts not an NVH with two names
0943f8
@@ -592,6 +600,7 @@
0943f8
                     ic = new_ipaddr_chain(p, s, sar);
0943f8
                     ic->next = default_list;
0943f8
                     default_list = ic;
0943f8
+                    add_name_vhost_config(p, main_s, s, sar, ic);
0943f8
                 }
0943f8
                 has_default_vhost_addr = 1;
0943f8
             }
0943f8
@@ -609,8 +618,9 @@
0943f8
                     ic->next = *iphash_table_tail[bucket];
0943f8
                     *iphash_table_tail[bucket] = ic;
0943f8
                 }
0943f8
+                add_name_vhost_config(p, main_s, s, sar, ic);
0943f8
             }
0943f8
-            add_name_vhost_config(p, main_s, s, sar, ic);
0943f8
+            sar_prev = sar;
0943f8
         }
0943f8
 
0943f8
         /* Ok now we want to set up a server_hostname if the user was