From: William A. Rowe Jr Date: Fri, 9 Nov 2001 16:54:00 +0000 (+0000) Subject: Stat, don't lstat the final target. This means we may double-stat the X-Git-Tag: 2.0.29~211 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51c6b901bf1b1689746a69763d95c95d5e3014a5;p=apache Stat, don't lstat the final target. This means we may double-stat the final target file if check for symlinks reveals it's an APR_LNK, but this is preferable to the convoluted code required to 'reuse' the original stat. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91822 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/request.c b/server/request.c index 1c848588e6..75c1e6fb06 100644 --- a/server/request.c +++ b/server/request.c @@ -504,8 +504,8 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r) * types of failure, such as APR_ENOTDIR. We can do something * with APR_ENOENT, knowing that the path is good. */ - if (!r->finfo.filetype) { - apr_lstat(&r->finfo, r->filename, APR_FINFO_MIN, r->pool); + if (!r->finfo.filetype || r->finfo.filetype == APR_LNK) { + apr_stat(&r->finfo, r->filename, APR_FINFO_MIN, r->pool); } if (r->finfo.filetype == APR_REG) { @@ -844,21 +844,13 @@ minimerge2: && (strncmp(r->filename, r->canonical_filename, filename_len) == 0)) #endif - && ((opts & (OPT_SYM_OWNER | OPT_SYM_LINKS)) == OPT_SYM_LINKS)) { + && ((opts & (OPT_SYM_OWNER | OPT_SYM_LINKS)) == OPT_SYM_LINKS)) + { + thisinfo.filetype = APR_DIR; ++seg; continue; } - - /* XXX: Optimization required: - * If...we have allowed symlinks, and - * if...we find the segment exists in the directory list - * skip the lstat and dummy up an APR_DIR value for thisinfo - * this means case sensitive platforms go quite quickly. - * Case insensitive platforms might be given the wrong path, - * but if it's not found in the cache, then we know we have - * something to test (the misspelling is never cached.) - */ /* We choose apr_lstat here, rather that apr_stat, so that we * capture this path object rather than its target. We will @@ -890,7 +882,8 @@ minimerge2: "access to %s failed", r->uri); return r->status = HTTP_FORBIDDEN; } - else if ((res = check_safe_file(r))) { + + if ((res = check_safe_file(r))) { r->status = res; return res; } @@ -939,7 +932,7 @@ minimerge2: /* If we have _not_ optimized, this is the time to recover * the final stat result. */ - if (!r->finfo.filetype) { + if (!r->finfo.filetype || r->finfo.filetype == APR_LNK) { r->finfo = thisinfo; }