Fix canonicalize_path so "../.." isn't stripped off and ignored.
authorBruce Momjian <bruce@momjian.us>
Thu, 11 Aug 2005 03:53:25 +0000 (03:53 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 11 Aug 2005 03:53:25 +0000 (03:53 +0000)
src/port/path.c

index a992094d4a8e86104bfcad5da8f131cb0e4aee6f..04118f78d30a9e7fd1f53e751f898b3cf09aed58 100644 (file)
@@ -284,7 +284,10 @@ canonicalize_path(char *path)
 
                if (len > 2 && strcmp(path + len - 2, "/.") == 0)
                        trim_directory(path);
-               else if (len > 3 && strcmp(path + len - 3, "/..") == 0)
+               /* We can only deal with "/usr/local/..", not "/usr/local/../.." */
+               else if (len > 3 && strcmp(path + len - 3, "/..") == 0 &&
+                                (len != 5 || strcmp(path, "../..") != 0) &&
+                                (len < 6 || strcmp(path + len - 6, "/../..") != 0))
                {
                        trim_directory(path);
                        trim_directory(path);   /* remove directory above */