From: Jeremy Koritzinsky Date: Sun, 7 Apr 2019 00:47:13 +0000 (-0700) Subject: Normalize directory separators before calling LoadLibrary (#23776) X-Git-Tag: accepted/tizen/unified/20190813.215958~51^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c94ba16ee00316548b2199ae8435b43e0f31894;p=platform%2Fupstream%2Fcoreclr.git Normalize directory separators before calling LoadLibrary (#23776) * Normalize directory separators when loading native library via ALC.LoadUnmanagedDllFromPath --- diff --git a/src/utilcode/longfilepathwrappers.cpp b/src/utilcode/longfilepathwrappers.cpp index af77a01..bfeb96d 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);