summaryrefslogtreecommitdiff
path: root/src/utilcode
diff options
context:
space:
mode:
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>2019-04-06 17:47:13 -0700
committerAaron Robinson <arobins@microsoft.com>2019-04-06 17:47:13 -0700
commit5c94ba16ee00316548b2199ae8435b43e0f31894 (patch)
tree10dfad52fc692a0aa818e3518b199a81a88ea9fc /src/utilcode
parent1f1801ff0d983bbedea00fca3b8ecc674eaddc13 (diff)
downloadcoreclr-5c94ba16ee00316548b2199ae8435b43e0f31894.tar.gz
coreclr-5c94ba16ee00316548b2199ae8435b43e0f31894.tar.bz2
coreclr-5c94ba16ee00316548b2199ae8435b43e0f31894.zip
Normalize directory separators before calling LoadLibrary (#23776)
* Normalize directory separators when loading native library via ALC.LoadUnmanagedDllFromPath
Diffstat (limited to 'src/utilcode')
-rw-r--r--src/utilcode/longfilepathwrappers.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utilcode/longfilepathwrappers.cpp b/src/utilcode/longfilepathwrappers.cpp
index af77a01e55..bfeb96d635 100644
--- a/src/utilcode/longfilepathwrappers.cpp
+++ b/src/utilcode/longfilepathwrappers.cpp
@@ -30,6 +30,10 @@ public:
static BOOL IsDevice(SString & path);
static HRESULT NormalizePath(SString& path);
+
+#ifndef FEATURE_PAL
+ static void NormalizeDirectorySeparators(SString& path);
+#endif
};
HMODULE
@@ -59,6 +63,7 @@ LoadLibraryExWrapper(
#ifndef FEATURE_PAL
//Adding the assert to ensure relative paths which are not just filenames are not used for LoadLibrary Calls
_ASSERTE(!LongFile::IsPathNotFullyQualified(path) || !LongFile::ContainsDirectorySeparator(path));
+ LongFile::NormalizeDirectorySeparators(path);
#endif //FEATURE_PAL
ret = LoadLibraryExW(path.GetUnicode(), hFile, dwFlags);
@@ -1173,6 +1178,17 @@ const WCHAR* LongFile::DevicePathPrefix = W("\\\\.\\");
const WCHAR* LongFile::UNCExtendedPathPrefix = W("\\\\?\\UNC\\");
const WCHAR* LongFile::UNCPathPrefix = UNCPATHPREFIX;
+void LongFile::NormalizeDirectorySeparators(SString& path)
+{
+ for(SString::Iterator i = path.Begin(); i < path.End(); ++i)
+ {
+ if (*i == AltDirectorySeparatorChar)
+ {
+ path.Replace(i, DirectorySeparatorChar);
+ }
+ }
+}
+
BOOL LongFile::IsExtended(SString & path)
{
return path.BeginsWith(ExtendedPrefix);