* path.cc (chdir): Check error conditions first.

This commit is contained in:
Corinna Vinschen 2009-06-18 09:47:13 +00:00
parent e53c92a80e
commit 1279c76b6a
2 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2009-06-18 Corinna Vinschen <corinna@vinschen.de>
* path.cc (chdir): Check error conditions first.
2009-06-17 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::recv_internal): Mark WSARecvMsg

View File

@ -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;