dgaudet     98/01/31 20:54:48

  Modified:    src      CHANGES
               src/main http_vhost.c
  Log:
  Fix a bug I introduced with http_vhost.c... r->hostname is supposed to
  always have :port removed from it.
  
  Revision  Changes    Path
  1.609     +3 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.608
  retrieving revision 1.609
  diff -u -r1.608 -r1.609
  --- CHANGES   1998/01/31 00:24:29     1.608
  +++ CHANGES   1998/02/01 04:54:45     1.609
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3b4
   
  +  *) Fix a bug where r->hostname didn't have the :port stripped
  +     from it.  [Dean Gaudet]
  +
     *) Tweaked the headers_out table size, and the subprocess_env
        table size guess in rename_original_environment().  Added
        MAKE_TABLE_PROFILE which can help discover make_table()
  
  
  
  1.5       +23 -11    apache-1.3/src/main/http_vhost.c
  
  Index: http_vhost.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_vhost.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- http_vhost.c      1998/01/28 11:33:22     1.4
  +++ http_vhost.c      1998/02/01 04:54:47     1.5
  @@ -587,6 +587,24 @@
    * run-time vhost matching functions
    */
   
  +/* Remove :port and optionally a single trailing . from the hostname, this
  + * canonicalizes it somewhat.
  + */
  +static void fix_hostname(request_rec *r)
  +{
  +    const char *hostname = r->hostname;
  +    char *host = getword(r->pool, &hostname, ':');   /* get rid of port */
  +    size_t l;
  +
  +    /* trim a trailing . */
  +    l = strlen(host);
  +    if (l > 0 && host[l-1] == '.') {
  +        host[l-1] = '\0';
  +    }
  +
  +    r->hostname = host;
  +}
  +
   static void check_hostalias(request_rec *r)
   {
       /*
  @@ -602,21 +620,12 @@
        * - except for the addresses from the VirtualHost line, none of the 
other
        *   names we'll match have ports associated with them
        */
  -    const char *hostname = r->hostname;
  -    char *host = getword(r->pool, &hostname, ':');      /* Get rid of port */
  +    const char *host = r->hostname;
       unsigned port = ntohs(r->connection->local_addr.sin_port);
       server_rec *s;
       server_rec *last_s;
  -    size_t l;
       name_chain *src;
   
  -    /* trim a trailing . */
  -    l = strlen(host);
  -    if (l > 0 && host[l-1] == '.') {
  -        host[l-1] = '\0';
  -    }
  -
  -    r->hostname = host;
       last_s = NULL;
   
       /* Recall that the name_chain is a list of server_addr_recs, some of
  @@ -730,14 +739,17 @@
   {
       /* check if we tucked away a name_chain */
       if (r->connection->vhost_lookup_data) {
  -        if (r->hostname || (r->hostname = table_get(r->headers_in, "Host")))
  +        if (r->hostname || (r->hostname = table_get(r->headers_in, "Host"))) 
{
  +         fix_hostname(r);
               check_hostalias(r);
  +     }
           else
               check_serverpath(r);
       }
       else if (!r->hostname) {
           /* must set this for HTTP/1.1 support */
           r->hostname = table_get(r->headers_in, "Host");
  +     fix_hostname(r);
       }
   }
   
  
  
  

Reply via email to