diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-05 17:15:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-05 17:16:25 -0400 |
commit | f882084dea25a64769006e7c991723a4bdcf9a6b (patch) | |
tree | cf0852a8347f9e16cb56ce9de580cd8497573aac /src/bin/psql/command.c | |
parent | 7c58a5f246dfab299e6c73c5ed9b04e7dc8d1745 (diff) | |
download | postgresql-f882084dea25a64769006e7c991723a4bdcf9a6b.tar.gz postgresql-f882084dea25a64769006e7c991723a4bdcf9a6b.zip |
Don't try to trim "../" in join_path_components().
join_path_components() tried to remove leading ".." components from its
tail argument, but it was not nearly bright enough to do so correctly
unless the head argument was (a) absolute and (b) canonicalized.
Rather than try to fix that logic, let's just get rid of it: there is no
correctness reason to remove "..", and cosmetic concerns can be taken
care of by a subsequent canonicalize_path() call. Per bug #6715 from
Greg Davidson.
Back-patch to all supported branches. It appears that pre-9.2, this
function is only used with absolute paths as head arguments, which is why
we'd not noticed the breakage before. However, third-party code might be
expecting this function to work in more general cases, so it seems wise
to back-patch.
In HEAD and 9.2, also make some minor cosmetic improvements to callers.
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 5614120255d..14a470a0d39 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -2051,10 +2051,10 @@ process_file(char *filename, bool single_txn, bool use_relative_path) * relative pathname, then prepend all but the last pathname component * of the current script to this pathname. */ - if (use_relative_path && pset.inputfile && !is_absolute_path(filename) - && !has_drive_prefix(filename)) + if (use_relative_path && pset.inputfile && + !is_absolute_path(filename) && !has_drive_prefix(filename)) { - snprintf(relpath, MAXPGPATH, "%s", pset.inputfile); + strlcpy(relpath, pset.inputfile, sizeof(relpath)); get_parent_directory(relpath); join_path_components(relpath, relpath, filename); canonicalize_path(relpath); |