Index: src/port/path.c =================================================================== RCS file: /cvsroot/pgsql/src/port/path.c,v retrieving revision 1.54 diff -c -c -r1.54 path.c *** src/port/path.c 12 Aug 2005 03:07:45 -0000 1.54 --- src/port/path.c 12 Aug 2005 04:47:59 -0000 *************** *** 226,231 **** --- 226,232 ---- { char *p, *to_p; bool was_sep = false; + int pending_strips = 0; #ifdef WIN32 /* *************** *** 284,306 **** if (len > 2 && strcmp(path + len - 2, "/.") == 0) trim_directory(path); ! /* ! * 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/../../..". ! */ ! 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 */ } else break; } } --- 285,311 ---- if (len > 2 && strcmp(path + len - 2, "/.") == 0) trim_directory(path); ! else if (len > 3 && strcmp(path + len - 3, "/..") == 0) { trim_directory(path); ! pending_strips++; ! } ! /* for absolute paths, we just keep trimming */ ! else if (*path != '\0' && pending_strips > 0) ! { ! trim_directory(path); ! pending_strips--; } else break; } + + if (pending_strips > 0) + { + for (; pending_strips > 0; pending_strips--) + strcat(path, "../"); + trim_trailing_separator(path); + } }