]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Ignore RewriteRules in .htaccess files if the directory
authorAndré Malo <nd@apache.org>
Thu, 31 Jul 2003 22:58:58 +0000 (22:58 +0000)
committerAndré Malo <nd@apache.org>
Thu, 31 Jul 2003 22:58:58 +0000 (22:58 +0000)
containing the .htaccess file is requested without a trailing slash.

PR: 20195
Reviewed by:    Justin Erenkrantz, Jeff Trawick

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

CHANGES
STATUS
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 4185ee714e7038e8f361af28074b1f013d2b0fc8..7a7c65d651a5ffa51d3171f467779dc51cc9fa49 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.48
 
+  *) mod_rewrite: Ignore RewriteRules in .htaccess files if the directory
+     containing the .htaccess file is requested without a trailing slash.
+     PR 20195.  [André Malo]
+
   *) ab: Overlong credentials given via command line no longer clobber
      the buffer.  [André Malo]
 
diff --git a/STATUS b/STATUS
index d0409d0c188214e8c8e70e7abe12c5c0230c9743..fe9428853f86078623204af753a8abb5b3227671 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2003/07/31 20:23:20 $]
+Last modified at [$Date: 2003/07/31 22:58:57 $]
 
 Release:
 
@@ -257,15 +257,6 @@ PATCHES TO PORT FROM 2.1
         modules/generators/mod_autoindex.c r1.120
       +1: nd, trawick
 
-    * Ignore RewriteRules in .htaccess files if the directory
-      containing the .htaccess file is requested without a trailing slash.
-      PR 20195.
-        modules/mappers/mod_rewrite.c: r1.156, 1.168
-      jerenkrantz says: We're doing 3 strlen's on the same value, can we please
-                        clean that up?
-            nd replies: of course ..., 1.168 does.
-      +1: nd, jerenkrantz, trawick
-
     * ab: Handle conditions where connect() on non-blocking socket
       doesn't complete immediately (i.e., restore functionality when
       benchmarking non-local targets).  This doesn't resolve some
index ae0090e967f2bf58029b87384c2c944c2357b21a..2d57a8ccf89dd4e33439aa3a66852988f47ffe75 100644 (file)
@@ -1402,7 +1402,7 @@ static int hook_fixup(request_rec *r)
     char *cp2;
     const char *ccp;
     char *prefix;
-    int l;
+    apr_size_t l;
     int rulestatus;
     int n;
     char *ofilename;
@@ -1426,6 +1426,18 @@ static int hook_fixup(request_rec *r)
         return DECLINED;
     }
 
+    /*
+     *  .htaccess file is called before really entering the directory, i.e.:
+     *  URL: http://localhost/foo  and .htaccess is located in foo directory
+     *  Ignore such attempts, since they may lead to undefined behaviour.
+     */
+    l = strlen(dconf->directory) - 1;
+    if (r->filename && strlen(r->filename) == l &&
+        (dconf->directory)[l] == '/' &&
+        !strncmp(r->filename, dconf->directory, l)) {
+        return DECLINED;
+    }
+
     /*
      *  only do something under runtime if the engine is really enabled,
      *  for this directory, else return immediately!