Bug 40187 - System.IO.Directory.CreateDirectory on Linux does not handle /.. in the path
Summary: System.IO.Directory.CreateDirectory on Linux does not handle /.. in the path
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 4.2.0 (C6)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-04-07 07:41 UTC by Kratzer Kevin
Modified: 2016-04-12 14:49 UTC (History)
2 users (show)

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


Attachments
Minimal Example Program (252 bytes, text/x-csharp)
2016-04-07 07:41 UTC, Kratzer Kevin
Details


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 Kratzer Kevin 2016-04-07 07:41:36 UTC
Created attachment 15640 [details]
Minimal Example Program

Example:
Ensure /tmp/test does not exist. Run the following program:


using System.IO;
class MainClass
{
    public static void Main (string[] args)
    {
        var path = "/tmp/test/multifolder/relativepath/not_this_folder";
        path = Path.Combine (path, "..");
        Directory.CreateDirectory (path);
    }
}


Expected result (as seen on Windows with adjusted paths):
The folder /tmp/test/multifolder/relativepath/ has been created

Observed result:
The folder /tmp/test/multifolder has been created and the following exception is thrown:

System.IO.DirectoryNotFoundException: Could not find a part of the path "/tmp/test/multifolder/relativepath/not_this_folder/.."
  at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0006b] in <filename unknown>:0
  at System.IO.Directory.CreateDirectory (System.String path) [0x000a4] in <filename unknown>:0
  at MainClass.Main (System.String[] args) [0x00014] in /home/kevin/Desktop/Test/TaskTEst/Program.cs:8

---------

> mono --version
Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 16 13:19:08 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

> cat /proc/version
Linux version 4.2.0-34-generic (buildd@lgw01-54) (gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) ) #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016


Xubuntu 15.10
Comment 1 Kratzer Kevin 2016-04-07 07:58:52 UTC
Addition: The same can be observed on Mac OS.
Comment 2 Marek Safar 2016-04-12 14:49:50 UTC
Fixed in master