Skip to content

Instantly share code, notes, and snippets.

@rfht
Created June 25, 2019 16:43
Show Gist options
  • Select an option

  • Save rfht/584be90adb030de726b6737ec77e3063 to your computer and use it in GitHub Desktop.

Select an option

Save rfht/584be90adb030de726b6737ec77e3063 to your computer and use it in GitHub Desktop.
Path.GetFullPath() bug demo
using System;
using System.IO;
class GetFullPathBugDemo
{
public static void Main(string[] args)
{
Console.WriteLine("Test with rooted path:");
Console.WriteLine(Path.GetFullPath(Directory.GetCurrentDirectory() + @"/test//test//test//"));
Console.WriteLine("Test with relative path:");
Console.WriteLine(Path.GetFullPath(@"test//test//test//"));
}
}
@rfht
Copy link
Copy Markdown
Author

rfht commented Jun 25, 2019

On Windows 10:

C:\temp>mono --version
Mono JIT compiler version 5.20.1 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       preemptive
        GC:            sgen (concurrent by default)

C:\temp>mono GetFullPathBugDemo.exe
Test with rooted path:
C:\temp\test\test\test\
Test with relative path:
C:\temp\test\test\test\

C:\temp>

@rfht
Copy link
Copy Markdown
Author

rfht commented Jun 25, 2019

On OpenBSD:

thfr@ryz.domain:tmp$ mono --version
Mono JIT compiler version 5.20.1.19 (tarball Mon Jun 24 09:30:38 MDT 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           
	SIGSEGV:       normal
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	Interpreter:   yes
	LLVM:          supported, not enabled.
	Suspend:       cooperative
	GC:            sgen (concurrent by default)

thfr@ryz.domain:tmp$ mono ~/obsd/ports/mono/GetFullPathBugDemo.exe
Test with rooted path:
/tmp/test/test/test/
Test with relative path:
/tmp/test//test//test//

thfr@ryz.domain:tmp$

@rfht
Copy link
Copy Markdown
Author

rfht commented Jun 25, 2019

On Ubuntu:

thfr@thfr-MS-7B79:/tmp$ mono --version
Mono JIT compiler version 5.20.1.19 (tarball Thu Apr 11 09:02:17 UTC 2019)
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 
	Interpreter:   yes
	LLVM:          yes(600)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)

thfr@thfr-MS-7B79:/tmp$ mono GetFullPathBugDemo.exe
Test with rooted path:
/tmp/test/test/test/
Test with relative path:
/tmp/test//test//test//

thfr@thfr-MS-7B79:/tmp$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment