mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-31 05:14:11 +02:00
Recuce DLL hijack risk on Windows
Don't call LoadLibrary() on shell32.dll or kernel32.dll. kernel32.dll is always loaded. Shell32.dll is also already loaded as glib links to functions in it. So just call GetModuleHandle() on them. For mlang.dll in win_iconv.c and winhttp.dll in gwinhttpvfs.c, always try loading them from a complete path, from the Windows system directory. Use the "tool help" API to enumerate modules in gmodule-win32.c. It is present in all Windows versions since Windows 2000, which is all we support anyway. Thus no need to look that API up dynamically. Just link to it normally. We can bin the fallback code that attempts to use the psapi API.
This commit is contained in:
@@ -706,10 +706,20 @@ static RFC1766TOLCIDA Rfc1766ToLcidA;
|
||||
static int
|
||||
load_mlang()
|
||||
{
|
||||
HMODULE h;
|
||||
HMODULE h = NULL;
|
||||
char mlang_dll[MAX_PATH + 100];
|
||||
int n;
|
||||
if (ConvertINetString != NULL)
|
||||
return TRUE;
|
||||
h = LoadLibrary("mlang.dll");
|
||||
n = GetSystemDirectory(mlang_dll, MAX_PATH);
|
||||
if (n > 0 && n < MAX_PATH)
|
||||
{
|
||||
if (mlang_dll[n-1] != '\\' &&
|
||||
mlang_dll[n-1] != '/')
|
||||
strcat(mlang_dll, "\\");
|
||||
strcat(mlang_dll, "mlang.dll");
|
||||
h = LoadLibrary(mlang_dll);
|
||||
}
|
||||
if (!h)
|
||||
return FALSE;
|
||||
ConvertINetString = (CONVERTINETSTRING)GetProcAddress(h, "ConvertINetString");
|
||||
|
Reference in New Issue
Block a user