diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4488c864d..3bee988c1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2009-06-18 Corinna Vinschen + + * path.cc (chdir): Check error conditions first. + 2009-06-17 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::recv_internal): Mark WSARecvMsg diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 7477ac5c9..56bf6aece 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2575,7 +2575,11 @@ chdir (const char *in_dir) bool doit = false; const char *posix_cwd = NULL; int devn = path.get_devn (); - if (!isvirtual_dev (devn)) + if (!path.exists ()) + set_errno (ENOENT); + else if (!path.isdir ()) + set_errno (ENOTDIR); + else if (!isvirtual_dev (devn)) { /* The sequence chdir("xx"); chdir(".."); must be a noop if xx is not a symlink. This is exploited by find.exe. @@ -2587,10 +2591,6 @@ chdir (const char *in_dir) res = 0; doit = true; } - else if (!path.exists ()) - set_errno (ENOENT); - else if (!path.isdir ()) - set_errno (ENOTDIR); else { posix_cwd = path.normalized_path;