diff options
author | Christopher Faylor <me@cgf.cx> | 2000-07-29 21:35:08 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-07-29 21:35:08 +0400 |
commit | 6043a545e38bebe90dd097be162fc3791dfad537 (patch) | |
tree | 92a3614cfc626bbac1150be42406175cbf8933b9 | |
parent | 0b1e683963404c645880c43933cb12f58c2eed4d (diff) |
* path.cc (chdir): Avoid trailing dot calculation when chdir == '/' or we endunlabeled-1.39.2
up with an empty string.
-rw-r--r-- | winsup/cygwin/path.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index a46ac4f41..4c6e1f715 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2601,8 +2601,7 @@ getwd (char *buf) } /* chdir: POSIX 5.2.1.1 */ -extern "C" -int +extern "C" int chdir (const char *dir) { syscall_printf ("dir %s", dir); @@ -2642,7 +2641,7 @@ chdir (const char *dir) of dots > 2 here instead of returning an error code. Counts of dots <= 2 are already eliminated by normalize_posix_path. */ char *last_slash = strrchr (pathbuf, '/'); - if (last_slash && strspn (last_slash + 1, ".") == strlen (last_slash + 1)) + if (last_slash > pathbuf && strspn (last_slash + 1, ".") == strlen (last_slash + 1)) *last_slash = '\0'; free (cwd_posix); cwd_posix = strdup (pathbuf); |