httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/generators mod_autoindex.c
Date Fri, 03 Aug 2001 01:31:26 GMT
wrowe       01/08/02 18:31:26

  Modified:    modules/generators mod_autoindex.c
  Log:
    Fix some major brokenness.  We were not validating that the autoindex
    subrequest'ed file was valid, and did not check a subrequest at all if
    the user didn't use FancyIndexing.
  
  Revision  Changes    Path
  1.75      +30 -23    httpd-2.0/modules/generators/mod_autoindex.c
  
  Index: mod_autoindex.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_autoindex.c,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- mod_autoindex.c	2001/08/03 01:00:12	1.74
  +++ mod_autoindex.c	2001/08/03 01:31:26	1.75
  @@ -1146,6 +1146,7 @@
   					request_rec *r, char keyid,
   					char direction)
   {
  +    request_rec *rr;
       struct ent *p;
   
       if ((dirent->name[0] == '.') && (!dirent->name[1])) {
  @@ -1156,6 +1157,16 @@
           return (NULL);
       }
   
  +    if (!(rr = ap_sub_req_lookup_dirent(dirent, r, NULL))) {
  +        return (NULL);
  +    }
  +
  +    if ((rr->finfo.filetype != APR_DIR && rr->finfo.filetype != APR_REG)
  +        || rr->status != OK) {
  +        ap_destroy_sub_req(rr);
  +        return (NULL);
  +    }
  +
       p = (struct ent *) apr_pcalloc(r->pool, sizeof(struct ent));
       p->name = apr_pstrdup(r->pool, dirent->name);
       p->size = -1;
  @@ -1166,40 +1177,36 @@
       p->key = apr_toupper(keyid);
       p->ascending = (apr_toupper(direction) == D_ASCENDING);
       p->version_sort = autoindex_opts & VERSION_SORT;
  -
  -    if (autoindex_opts & FANCY_INDEXING) {
  -        request_rec *rr = ap_sub_req_lookup_dirent(dirent, r, NULL);
  -
  -	if (rr->finfo.filetype != 0) {
  -	    p->lm = rr->finfo.mtime;
  -	    if (rr->finfo.filetype == APR_DIR) {
  -	        if (!(p->icon = find_icon(d, rr, 1))) {
  -		    p->icon = find_default_icon(d, "^^DIRECTORY^^");
  -		}
  -		if (!(p->alt = find_alt(d, rr, 1))) {
  -		    p->alt = "DIR";
  -		}
  -		p->size = -1;
  -		p->name = apr_pstrcat(r->pool, dirent->name, "/", NULL);
  + 
  +    if (autoindex_opts & FANCY_INDEXING) 
  +    {
  +	p->lm = rr->finfo.mtime;
  +	if (rr->finfo.filetype == APR_DIR) {
  +	    if (!(p->icon = find_icon(d, rr, 1))) {
  +		p->icon = find_default_icon(d, "^^DIRECTORY^^");
   	    }
  -	    else {
  -		p->icon = find_icon(d, rr, 0);
  -		p->alt = find_alt(d, rr, 0);
  -		p->size = rr->finfo.size;
  +	    if (!(p->alt = find_alt(d, rr, 1))) {
  +		p->alt = "DIR";
   	    }
  +	    p->size = -1;
  +	    p->name = apr_pstrcat(r->pool, dirent->name, "/", NULL);
   	}
  +	else {
  +	    p->icon = find_icon(d, rr, 0);
  +	    p->alt = find_alt(d, rr, 0);
  +	    p->size = rr->finfo.size;
  +	}
   
   	p->desc = find_desc(d, rr);
   
   	if ((!p->desc) && (autoindex_opts & SCAN_HTML_TITLES)) {
   	    p->desc = apr_pstrdup(r->pool, find_title(rr));
   	}
  -
  -	ap_destroy_sub_req(rr);
       }
  +    ap_destroy_sub_req(rr);
       /*
  -     * We don't need to take any special action for the file size key.  If
  -     * we did, it would go here.
  +     * We don't need to take any special action for the file size key.
  +     * If we did, it would go here.
        */
       if (keyid == K_LAST_MOD) {
           if (p->lm < 0) {
  
  
  

Mime
View raw message