You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Roy Fielding <fi...@hyperreal.com> on 1996/12/01 14:48:24 UTC

cvs commit: apache/src mod_access.c

fielding    96/12/01 05:48:23

  Modified:    src       mod_access.c
  Log:
  Fix bug reported by Dean Gaudet regarding hostnames which begin with
  a digit being improperly treated as IP addresses in find_allowdeny.
  Reviewed by: Randy Terbush, Chuck Murcko
  
  Revision  Changes    Path
  1.11      +21 -9     apache/src/mod_access.c
  
  Index: mod_access.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_access.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -C3 -r1.10 -r1.11
  *** mod_access.c	1996/11/18 19:40:49	1.10
  --- mod_access.c	1996/12/01 13:48:23	1.11
  ***************
  *** 167,178 ****
        return (what[l] == '\0' || what[l] == '.');
    }
    
    int find_allowdeny (request_rec *r, array_header *a, int method)
    {
        allowdeny *ap = (allowdeny *)a->elts;
        int mmask = (1 << method);
  !     int i, gothost=0;
  !     const char *remotehost=NULL;
    
        for (i = 0; i < a->nelts; ++i) {
            if (!(mmask & ap[i].limited))
  --- 167,185 ----
        return (what[l] == '\0' || what[l] == '.');
    }
    
  + static int is_ip(const char *host)
  + {
  +     while (*host && ((*host == '.') || isdigit(*host))) host++;
  +     return (*host == '\0');
  + }
  + 
    int find_allowdeny (request_rec *r, array_header *a, int method)
    {
        allowdeny *ap = (allowdeny *)a->elts;
        int mmask = (1 << method);
  !     int i;
  !     int gothost = 0;
  !     const char *remotehost = NULL;
    
        for (i = 0; i < a->nelts; ++i) {
            if (!(mmask & ap[i].limited))
  ***************
  *** 191,205 ****
    	
    	if (!strcmp (ap[i].from, "all"))
    	    return 1;
  ! 	if (!gothost)
  ! 	{
    	    remotehost = get_remote_host(r->connection, r->per_dir_config,
  ! 					 REMOTE_HOST);
  ! 	    gothost = 1;
    	}
  !         if (remotehost != NULL && isalpha(remotehost[0]))
  !             if (in_domain(ap[i].from, remotehost))
  !                 return 1;
            if (in_ip (ap[i].from, r->connection->remote_ip))
                return 1;
        }
  --- 198,217 ----
    	
    	if (!strcmp (ap[i].from, "all"))
    	    return 1;
  ! 
  ! 	if (!gothost) {
    	    remotehost = get_remote_host(r->connection, r->per_dir_config,
  ! 	                                 REMOTE_HOST);
  ! 
  ! 	    if ((remotehost == NULL) || is_ip(remotehost))
  ! 	        gothost = 1;
  ! 	    else
  ! 	        gothost = 2;
    	}
  ! 
  !         if ((gothost == 2) && in_domain(ap[i].from, remotehost))
  !             return 1;
  ! 
            if (in_ip (ap[i].from, r->connection->remote_ip))
                return 1;
        }