Document why we only handle trailing "..".
authorBruce Momjian <[email protected]>
Fri, 12 Aug 2005 02:48:37 +0000 (02:48 +0000)
committerBruce Momjian <[email protected]>
Fri, 12 Aug 2005 02:48:37 +0000 (02:48 +0000)
src/port/path.c

index 04118f78d30a9e7fd1f53e751f898b3cf09aed58..88978e062ed451cb2139bd423c107704856ecf31 100644 (file)
@@ -284,7 +284,13 @@ canonicalize_path(char *path)
 
                if (len > 2 && strcmp(path + len - 2, "/.") == 0)
                        trim_directory(path);
-               /* We can only deal with "/usr/local/..", not "/usr/local/../.." */
+               /*
+                *      Process only a single trailing "..", and only if ".." does
+                *      not preceed it.
+                *      So, we only deal with "/usr/local/..", not with "/usr/local/../..".
+                *      We don't handle the even more complex cases, like
+                *      "usr/local/../../.." and "usr/local/../bin/../..".
+                */
                else if (len > 3 && strcmp(path + len - 3, "/..") == 0 &&
                                 (len != 5 || strcmp(path, "../..") != 0) &&
                                 (len < 6 || strcmp(path + len - 6, "/../..") != 0))