]> granicus.if.org Git - apache/commitdiff
* Although the lstat call should rarely ever fail, because we stat'ed the
authorRuediger Pluem <rpluem@apache.org>
Tue, 25 Jul 2006 13:40:32 +0000 (13:40 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 25 Jul 2006 13:40:32 +0000 (13:40 +0000)
  same file several lines above, check the return value to be save that
  nothing bad happens in the case it does fail.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@425394 13f79535-47bb-0310-9956-ffa450edef68

server/request.c

index dfcbbe13af739530c4c36a3f5eaa208f991aa0af..4948736fa48222e63304995faad64a8af69bc2fc 100644 (file)
@@ -553,9 +553,22 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r)
              * check.
              */
             if (!(opts & OPT_SYM_LINKS)) {
-                apr_stat(&thisinfo, r->filename,
-                         APR_FINFO_MIN | APR_FINFO_NAME | APR_FINFO_LINK,
-                         r->pool);
+                rv = apr_stat(&thisinfo, r->filename,
+                              APR_FINFO_MIN | APR_FINFO_NAME | APR_FINFO_LINK,
+                              r->pool);
+                if (rv != APR_SUCCESS) {
+                    /*
+                     * This should never happen, because we did a stat on the
+                     * same file, resolving a possible symlink several lines
+                     * above. Therefore do not make a detailed analysis of rv
+                     * in this case for the reason of the failure, just bail out
+                     * with a HTTP_FORBIDDEN in case we hit a race condition
+                     * here.
+                     */
+                    ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                                  "access to %s failed", r->uri);
+                    return r->status = HTTP_FORBIDDEN;
+                }
                 if (thisinfo.filetype == APR_LNK) {
                     /* Is this a possibly acceptable symlink? */
                     if ((res = resolve_symlink(r->filename, &thisinfo,