Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Christoforides <alexis@thenull.net>2017-11-17 01:19:28 +0300
committerMarek Safar <marek.safar@gmail.com>2017-11-17 13:31:44 +0300
commit3e1eeec6c3373b38688b714f354da72dc2d92247 (patch)
treef310bf6ca6e5618d6af716c38fe9553b136e6414 /mcs/class/corlib/System.IO
parent2bb178c7a818fff79aee95ae3513c258692b82dc (diff)
[System.IO] Directory.Exists() now resolves the full path first. Fixes #60267
In Unix, assume our current directory contains: `test`, a directory `test/test2`, another directory `test/test2/test_file`, a file `test3`, a symbolic link pointing to `test/test2` Then the path "test3/../test3" has two interpretations depending on the processor: * The OS (the `lstat` syscall, `ls`, etc.) will find it invalid (as it evaluates to: enter `test/test2`, go up one level, try to enter `test3` which is another level down * We (.NET, at least CoreCLR) should find it valid (enter `test3`, go up one level, enter `test3`). This ensures that for Directory.Exists, we process the path `..`'s on the .NET level before passing it for native processing.
Diffstat (limited to 'mcs/class/corlib/System.IO')
-rw-r--r--mcs/class/corlib/System.IO/Directory.cs13
1 files changed, 10 insertions, 3 deletions
diff --git a/mcs/class/corlib/System.IO/Directory.cs b/mcs/class/corlib/System.IO/Directory.cs
index cab5f3ee047..755e8510816 100644
--- a/mcs/class/corlib/System.IO/Directory.cs
+++ b/mcs/class/corlib/System.IO/Directory.cs
@@ -195,11 +195,18 @@ namespace System.IO
// on Moonlight this does not throw but returns false
if (!SecurityManager.CheckElevatedPermissions ())
return false;
-
+
+ string full_path;
+ try {
+ full_path = Path.GetFullPath (path);
+ } catch {
+ return false;
+ }
+
MonoIOError error;
bool exists;
-
- exists = MonoIO.ExistsDirectory (path, out error);
+
+ exists = MonoIO.ExistsDirectory (full_path, out error);
/* This should not throw exceptions */
return exists;
}