Fix win32 file name canonicalization.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 31 Mar 2011 19:08:55 +0000 (16:08 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 31 Mar 2011 19:11:26 +0000 (16:11 -0300)
* 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.

mono/utils/mono-path.c

index ca71d98996f1efaed0742bfabaaa922f559aa6c7..e04c3dfe8b9f46519816c61b90b9a835e9f2c44d 100644 (file)
@@ -81,8 +81,11 @@ mono_path_canonicalize (const char *path)
                pos = strchr (lastpos, G_DIR_SEPARATOR);
        }
 
-#ifdef HOST_WIN32 /* For UNC paths the first '\' is removed. */
-       if (*(lastpos-1) == G_DIR_SEPARATOR && *(lastpos-2) == G_DIR_SEPARATOR)
+#ifdef HOST_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