httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: Poss. bug in directory_walk
Date Mon, 07 Oct 1996 15:35:05 GMT
Paul Sutton wrote:
> 
> I think there is a possible bug in directory_walk. If the request is for a
> directory which ends with a /, any .htaccess file in that directory gets
> merged _twice_. The reason for this is that the directory walk first finds
> the number of dir segments in the path (with count_dirs(), which just
> counts the number of /'s), then if the path is a directory, it adds 1. So
> requests for
> 
>   /usr/www/1/index.html
> and
>   /usr/www/1
> 
> are regarded as having 4 directories (correct), but

Errr ... but if count_dirs() just counts /s then these should have different
numbers.

> 
>   /usr/www/1/
> 
> has 5 directories (incorrect). The directories are then processed by
> directory_walk:
> 
>   1   /
>   2   /usr
>   3   /usr/www
>   4   /usr/www/1
>   5   /usr/www/1/
> 
> 4 and 5 refer to the same directory, and any .htaccess in this directory
> will be included twice. I guess there might be a good reason for this, but
> merging a per-dir config twice might cause unwanted effects.
> 
> A fix for this is given below.

I think fixing count_dirs() would make more sense...

Cheers,

Ben.

> 
> Paul
> UK Web Ltd
> 
> *** ../src/http_request.c	Thu Aug 22 08:36:53 1996
> --- ./http_request.c	Mon Oct  7 15:09:25 1996
> ***************
> *** 271,276 ****
> --- 271,279 ----
>       no2slash (test_filename);
>       num_dirs = count_dirs(test_filename);
>       get_path_info (r);
> +
> +     if (test_filename[strlen(test_filename)-1] == '/')
> +         --num_dirs;
> 
>       if (S_ISDIR (r->finfo.st_mode)) ++num_dirs;
> 
> 
> 

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.            Apache Group member (http://www.apache.org)

Mime
View raw message