Skip to content
Browse files

Fix win32 file name canonicalization.

	* mono-path.c (mono_path_canonicalize): Properly canonicalize
	non UNC paths with an extra backslash. Eg:
	c:\foo\\bar was been canonicalized to c:\\foo\bar.

	This was breaking assembly loading in some rare cases.
  • Loading branch information...
1 parent 5d5011c commit 73dc0553b7cec85328681d541c2e61b755a26781 @kumpera kumpera committed
Showing with 5 additions and 2 deletions.
  1. +5 −2 mono/utils/mono-path.c
View
7 mono/utils/mono-path.c
@@ -73,8 +73,11 @@ mono_path_canonicalize (const char *path)
pos = strchr (lastpos, G_DIR_SEPARATOR);
}
-#ifdef PLATFORM_WIN32 /* For UNC paths the first '\' is removed. */
- if (*(lastpos-1) == G_DIR_SEPARATOR && *(lastpos-2) == G_DIR_SEPARATOR)
+#ifdef PLATFORM_WIN32
+ /* Avoid removing the first '\' for UNC paths. We must make sure that it's indeed an UNC path
+ by checking if the \\ pair happens exactly at the end of the string.
+ */
+ if (*(lastpos-1) == G_DIR_SEPARATOR && *(lastpos-2) == G_DIR_SEPARATOR && *lastpos == 0)
lastpos = lastpos-1;
#endif

0 comments on commit 73dc055

Please sign in to comment.
Something went wrong with that request. Please try again.