diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-08-03 11:14:09 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-08-03 11:14:09 +0000 |
commit | dce6f5639766db7bafd72308ebd1c848d257e2ef (patch) | |
tree | 1f6b43b64215d09a5480f8ea8dd13e420756df32 /winsup/cygwin/path.cc | |
parent | 20b2e9ce39c4f194e1ca94823740df739fcdc42d (diff) | |
download | cygnal-dce6f5639766db7bafd72308ebd1c848d257e2ef.tar.gz cygnal-dce6f5639766db7bafd72308ebd1c848d257e2ef.tar.bz2 cygnal-dce6f5639766db7bafd72308ebd1c848d257e2ef.zip |
* path.cc (fchdir): Set the fhandler's path to absolute value to
ensure changing to the correct directory even if the fhandler originally
points to a relative path.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 575d64f98..bd032d759 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3092,6 +3092,25 @@ fchdir (int fd) return -1; } int ret = chdir (cygheap->fdtab[fd]->get_name ()); + if (!ret) + { + /* The name in the fhandler is explicitely overwritten with the full path. + Otherwise fchmod() to a path originally given as a relative path could + end up in a completely different directory. Imagine: + + fd = open (".."); + fchmod(fd); + fchmod(fd); + + The 2nd fchmod should chdir to the same dir as the first call, not + to it's parent dir. */ + char path[MAX_PATH]; + char posix_path[MAX_PATH]; + mount_table->conv_to_posix_path (cygheap->cwd.get (path, 0, 1), + posix_path, 0); + cygheap->fdtab[fd]->set_name (path, posix_path); + } + syscall_printf ("%d = fchdir (%d)", ret, fd); return ret; } |