summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c2
-rw-r--r--Src/compat.c11
-rw-r--r--Src/utils.c13
3 files changed, 18 insertions, 8 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 572a0dd68..3d34aa74c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1163,7 +1163,7 @@ cd_try_chdir(char *pfix, char *dest, int hard)
* or a parent directory is renamed in the interim.
*/
if (lchdir(buf, NULL, hard) &&
- (pfix || *dest == '/' || lchdir(dest, NULL, hard))) {
+ (pfix || *dest == '/' || lchdir(unmeta(dest), NULL, hard))) {
free(buf);
return NULL;
}
diff --git a/Src/compat.c b/Src/compat.c
index a0ce1823c..db468529a 100644
--- a/Src/compat.c
+++ b/Src/compat.c
@@ -454,8 +454,13 @@ zgetcwd(void)
return ret;
}
-/* chdir with arbitrary long pathname. Returns 0 on success, -1 on normal *
- * failure and -2 when chdir failed and the current directory is lost. */
+/*
+ * chdir with arbitrary long pathname. Returns 0 on success, -1 on normal *
+ * failure and -2 when chdir failed and the current directory is lost.
+ *
+ * This is to be treated as if at system level, so dir is unmetafied but
+ * terminated by a NULL.
+ */
/**/
mod_export int
@@ -465,7 +470,7 @@ zchdir(char *dir)
int currdir = -2;
for (;;) {
- if (!*dir || chdir(unmeta(dir)) == 0) {
+ if (!*dir || chdir(dir) == 0) {
#ifdef HAVE_FCHDIR
if (currdir >= 0)
close(currdir);
diff --git a/Src/utils.c b/Src/utils.c
index 20e01a207..4c4dc55cd 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -6440,10 +6440,15 @@ init_dirsav(Dirsav d)
d->dirfd = d->level = -1;
}
-/* Change directory, without following symlinks. Returns 0 on success, -1 *
- * on failure. Sets errno to ENOTDIR if any symlinks are encountered. If *
- * fchdir() fails, or the current directory is unreadable, we might end up *
- * in an unwanted directory in case of failure. */
+/*
+ * Change directory, without following symlinks. Returns 0 on success, -1
+ * on failure. Sets errno to ENOTDIR if any symlinks are encountered. If
+ * fchdir() fails, or the current directory is unreadable, we might end up
+ * in an unwanted directory in case of failure.
+ *
+ * path is an unmetafied but null-terminated string, as needed by system
+ * calls.
+ */
/**/
mod_export int