apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r424915 - /apr/apr/trunk/file_io/win32/filepath.c
Date Mon, 24 Jul 2006 05:53:31 GMT
Author: wrowe
Date: Sun Jul 23 22:53:31 2006
New Revision: 424915

URL: http://svn.apache.org/viewvc?rev=424915&view=rev
Log:
  
  Solve svn issue 1869, avoid replacing previous ../ segments when multiple
  ../../.. patterns are present.  This patch also normalizes the .. path
  seperators to use the same rules as normal paths, that is, if it's NATIVE
  use '\' (previous behavior), and (new behavior) if TRUENAME not NATIVE,
  use '/', otherwise the given slash.  Adds no trailing slash if none was
  present on input.  Solved with hints from Lieven Govaerts <lgo mobsol.be>.

  Resolves test fail identified by test/testnames.c commit 424831

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

Modified: apr/apr/trunk/file_io/win32/filepath.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filepath.c?rev=424915&r1=424914&r2=424915&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filepath.c (original)
+++ apr/apr/trunk/file_io/win32/filepath.c Sun Jul 23 22:53:31 2006
@@ -677,16 +677,22 @@
                 /* Otherwise this is simply a noop, above root is root.
                  */
             }
-            else if (pathlen == 0 ||
-                     (pathlen >= 3 && (pathlen == 3
-                                    || path[pathlen - 4] == ':')
-                                   &&  path[pathlen - 3] == '.' 
-                                   &&  path[pathlen - 2] == '.' 
-                                   && (path[pathlen - 1] == '/' 
-                                    || path[pathlen - 1] == '\\')))
+            else if (pathlen == 0 
+                      || (pathlen >= 3 
+                           && (pathlen == 3
+                                || path[pathlen - 4] == ':'
+                                || path[pathlen - 4] == '/' 
+                                || path[pathlen - 4] == '\\')
+                           &&  path[pathlen - 3] == '.' 
+                           &&  path[pathlen - 2] == '.' 
+                           && (path[pathlen - 1] == '/' 
+                                || path[pathlen - 1] == '\\')))
             {
-                /* Path is already backpathed or empty, if the
-                 * APR_FILEPATH_SECUREROOTTEST.was given die now.
+                /* Verified path is empty, exactly "..[/\]", or ends
+                 * in "[:/\]..[/\]" - these patterns we will not back
+                 * over since they aren't 'prior segements'.
+                 * 
+                 * If APR_FILEPATH_SECUREROOTTEST.was given, die now.
                  */
                 if (flags & APR_FILEPATH_SECUREROOTTEST)
                     return APR_EABOVEROOT;
@@ -695,9 +701,13 @@
                  */
                 if (pathlen + 3 >= sizeof(path))
                     return APR_ENAMETOOLONG;
-                memcpy(path + pathlen, ((flags & APR_FILEPATH_NATIVE) 
-                                          ? "..\\" : "../"), 3);
-                pathlen += 3;
+                path[pathlen++] = '.';
+                path[pathlen++] = '.';
+                if (addpath[segend]) {
+                    path[pathlen++] = ((flags & APR_FILEPATH_NATIVE) 
+                                    ? '\\' : ((flags & APR_FILEPATH_TRUENAME)
+                                           ? '/' : addpath[segend]));
+                }
                 /* The 'root' part of this path now includes the ../ path,
                  * because that backpath will not be parsed by the truename
                  * code below.



Mime
View raw message