Bug 17083 - Trying to open a path with many ".." throws exceptions
Summary: Trying to open a path with many ".." throws exceptions
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-07 00:15 UTC by john palmer
Modified: 2014-02-13 01:36 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description john palmer 2014-01-07 00:15:41 UTC
If you have a path that goes "above" / in the file system, an exception is thrown when trying to create a FileStream.

Here is a simple example

new FileStream("/../bin/bash",FileMode.Open,FileAccess.Read,FileShare.ReadWrite);;
System.IO.DirectoryNotFoundException: Could not find a part of the path "bin/bash".
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at <StartupCode$FSI_0007>.$FSI_0007.main@ () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

Using similar paths in bash works just fine and I believe "/../bin/bash" should be a valid path which goes to "/bin/bash".

This came up in this SO question: http://stackoverflow.com/questions/20959906/f-on-monodevelop-compiler-doesnt-understand-valid-linux-file-path.

Mono version is 3.2.3 on ArchLinux
Comment 1 john palmer 2014-01-08 19:37:55 UTC
I think the problem lies inside System.IO.Path.GetFullPath as

System.IO.Path.GetFullPath("/../bin/bash");


returns

bin/bash

which is obviously not correct
Comment 2 john palmer 2014-02-10 00:20:14 UTC
Hi,

It has been over a month with no response.

Is this bug report in any way unclear?

What can be done to get some progress on this?

Thanks,
Comment 3 Mikayla Hutchinson [MSFT] 2014-02-10 22:15:57 UTC
We haven't made any progress on this because its impact is very low and we're busy working on higher priority issues. If it's important to you, you're welcome to submit a patch.
Comment 4 Miguel de Icaza [MSFT] 2014-02-12 13:20:09 UTC
Fixed on master.
Comment 5 john palmer 2014-02-13 01:36:42 UTC
Thanks.