From 94ff0163de2795f47bc06d1f692f448aa6f6e4b9 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Fri, 3 Aug 2001 01:31:26 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89899 13f79535-47bb-0310-9956-ffa450edef68 --- modules/generators/mod_autoindex.c | 53 +++++++++++++++++------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 5f120d33d9..2fa571a06f 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -1146,6 +1146,7 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, request_rec *r, char keyid, char direction) { + request_rec *rr; struct ent *p; if ((dirent->name[0] == '.') && (!dirent->name[1])) { @@ -1156,6 +1157,16 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, 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,27 +1177,24 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, 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); @@ -1194,12 +1202,11 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, 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) { -- 2.40.0