apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject [Fwd: svn commit: r382095 - /apr/apr/trunk/file_io/win32/filepath.c]
Date Wed, 01 Mar 2006 23:37:35 GMT
Brad and I spent quite a bit of time this afternoon on what the original
code and new code do.  It raised a very interesting question.

If I, the developer, combine a relative -or- empty left hand side expression
and add a path that's *absolute*, but flagged the apr_filepath_merge as
APR_FILEPATH_NOTABOVEROOT, what happens?

My thought is that an empty or null left-hand side expression should
correspond conceptually to the cwd, or a totally unrooted location.

If that's true, then merging an absolute addpath should fail as above root(!)

What say you all?

Bill


-------- Original Message --------
Subject: svn commit: r382095 - /apr/apr/trunk/file_io/win32/filepath.c
Date: Wed, 01 Mar 2006 17:41:23 -0000
From: wrowe@apache.org
Reply-To: dev@apr.apache.org
To: commits@apr.apache.org

Author: wrowe
Date: Wed Mar  1 09:41:22 2006
New Revision: 382095

URL: http://svn.apache.org/viewcvs?rev=382095&view=rev
Log:

   Revert 239927 and simplify a much more basic optimization
   to address if a basepath existed to compare the results to.
   Also reverts my attempt 382043 to fix the flaw.

   Any further 'features' to support alternate constructs of
   NOTABOVEROOT tested base and add paths must be brought up
   on list for discussion.

PR: 38801
Reported by: <kevin_wise motorola.com>

Modified:
     apr/apr/trunk/file_io/win32/filepath.c

Modified: apr/apr/trunk/file_io/win32/filepath.c
URL: 
http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/win32/filepath.c?rev=382095&r1=382094&r2=382095&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filepath.c (original)
+++ apr/apr/trunk/file_io/win32/filepath.c Wed Mar  1 09:41:22 2006
@@ -800,18 +800,17 @@
       * is still within given basepath.  Note that the root path
       * segment is thoroughly tested prior to path parsing.
       */
-    if ((flags & APR_FILEPATH_NOTABOVEROOT) && (baselen || rootlen)) {
-        if (basepath[baselen - 1] != '/' && basepath[baselen - 1] != '\\') {
-            if (baselen && memcmp(basepath, path + rootlen, baselen))
-                return APR_EABOVEROOT;
-
-            /* Ahem... if we weren't given a trailing slash on the basepath,
-             * we better be sure that /foo wasn't replaced with /foobar!
-             */
-            if (path[rootlen + baselen] && path[rootlen + baselen] != '/'
-                                        && path[rootlen + baselen] != '\\')
-                return APR_EABOVEROOT;
-        }
+    if ((flags & APR_FILEPATH_NOTABOVEROOT) && baselen) {
+        if (memcmp(basepath, path + rootlen, baselen) != 0)
+            return APR_EABOVEROOT;
+
+         /* Ahem... if we have a basepath without a trailing slash,
+          * we better be sure that /foo wasn't replaced with /foobar!
+          */
+        if (basepath[baselen - 1] != '/' && basepath[baselen - 1] != '\\'
+              && path[rootlen + baselen] && path[rootlen + baselen] != '/'
+                                         && path[rootlen + baselen] != '\\')
+            return APR_EABOVEROOT;
      }

      if (addpath && (flags & APR_FILEPATH_TRUENAME)) {





Mime
View raw message