Reviewed by: Randy Terbush
Submitted by: Marc Slemko
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3@77424
13f79535-47bb-0310-9956-
ffa450edef68
}
#if defined(ENOENT)
else {
- log_reason("unable to determine if index file exists (stat() returned unexpected error)", r->filename, r);
+ log_printf(r->server, "access to %s failed for client; unable to determine if index file exists (stat() returned unexpected error)", r->filename);
return FORBIDDEN;
}
#endif
(dir_config_rec *)get_module_config (r->per_dir_config, &dir_module);
char *names_ptr = d->index_names ? d->index_names : DEFAULT_INDEX;
int allow_opts = allow_options (r);
+ int error_notfound = 0;
if (r->uri[0] == '\0' || r->uri[strlen(r->uri)-1] != '/') {
char* ifile;
return OK;
}
- destroy_sub_req (rr);
+ /* If the request returned something other than 404 (or 200),
+ * it means the module encountered some sort of problem. To be
+ * secure, we should return the error, rather than create
+ * along a (possibly unsafe) directory index.
+ *
+ * So we store the error, and if none of the listed files
+ * exist, we return the last error response we got, instead
+ * of a directory listing.
+ */
+ if (rr->status && rr->status != 404 && rr->status != 200)
+ error_notfound = rr->status;
+
+ destroy_sub_req (rr);
}
+ if (error_notfound)
+ return error_notfound;
+
if (r->method_number != M_GET) return NOT_IMPLEMENTED;
/* OK, nothing easy. Trot out the heavy artillery... */
(dir_config_rec *)get_module_config (r->per_dir_config, &dir_module);
char *names_ptr = d->index_names ? d->index_names : DEFAULT_INDEX;
int allow_opts = allow_options (r);
+ int error_notfound = 0;
if (r->uri[0] == '\0' || r->uri[strlen(r->uri)-1] != '/') {
char* ifile;
return OK;
}
- destroy_sub_req (rr);
+ /* If the request returned something other than 404 (or 200),
+ * it means the module encountered some sort of problem. To be
+ * secure, we should return the error, rather than create
+ * along a (possibly unsafe) directory index.
+ *
+ * So we store the error, and if none of the listed files
+ * exist, we return the last error response we got, instead
+ * of a directory listing.
+ */
+ if (rr->status && rr->status != 404 && rr->status != 200)
+ error_notfound = rr->status;
+
+ destroy_sub_req (rr);
}
+ if (error_notfound)
+ return error_notfound;
+
if (r->method_number != M_GET) return NOT_IMPLEMENTED;
/* OK, nothing easy. Trot out the heavy artillery... */