Bug 286382 - Don't load DLLs from the current directory; r=bsmedberg a=blocking-betaN+

This commit is contained in:
Ehsan Akhgari 2010-09-28 20:33:43 -04:00
parent d0803805a5
commit 2fdb64b721
3 changed files with 33 additions and 0 deletions

View File

@ -58,6 +58,17 @@ main(int argc, char* argv[])
MessageBox(NULL, L"Hi", L"Hi", MB_OK);
#endif
#ifdef XP_WIN
typedef BOOL
(WINAPI *pfnSetDllDirectory) (LPCWSTR);
pfnSetDllDirectory setDllDirectory =
reinterpret_cast<pfnSetDllDirectory>
(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDllDirectoryW"));
if (setDllDirectory) {
setDllDirectory(L"");
}
#endif
// Check for the absolute minimum number of args we need to move
// forward here. We expect the last arg to be the child process type.
if (argc < 1)

View File

@ -287,10 +287,23 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
}
#endif
typedef BOOL
(WINAPI *pfnSetDllDirectory) (LPCWSTR);
pfnSetDllDirectory setDllDirectory =
reinterpret_cast<pfnSetDllDirectory>
(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDllDirectoryW"));
if (setDllDirectory) {
setDllDirectory(NULL);
}
nsresult rv = plugin->Load(outLibrary);
if (NS_FAILED(rv))
*outLibrary = NULL;
if (setDllDirectory) {
setDllDirectory(L"");
}
#ifndef WINCE
if (restoreOrigDir) {
BOOL bCheck = SetCurrentDirectoryW(aOrigDir);

View File

@ -90,6 +90,15 @@ void ExtractEnvironmentFromCL(int &argc, char **&argv)
int wmain(int argc, WCHAR **argv)
{
typedef BOOL
(WINAPI *pfnSetDllDirectory) (LPCWSTR);
pfnSetDllDirectory setDllDirectory =
reinterpret_cast<pfnSetDllDirectory>
(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDllDirectoryW"));
if (setDllDirectory) {
setDllDirectory(L"");
}
#ifdef XRE_WANT_DLL_BLOCKLIST
SetupDllBlocklist();
#endif