From 71d8f118da24bb5a31f406e5fba222a324913b05 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 28 Aug 2010 11:22:37 +0000 Subject: * loadlib.h: New header implementing safe LoadLibrary calls. Include throughout files using LoadLibrary function. * cygcheck.cc (dump_sysinfo): Retrieve kernel32.dll handle via GetModuleHandle, rather than using LoadLibrary. * cygpath.cc (get_long_name): Ditto. (do_sysfolders): Append .dll suffix in LoadLibrary call. * ldh.cc (WinMain): Use LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES to avoid loading malicious library code. * locale.cc (print_locale_with_codeset): Change way to retrieve kernel32.dll path. --- winsup/utils/locale.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'winsup/utils/locale.cc') diff --git a/winsup/utils/locale.cc b/winsup/utils/locale.cc index 8dbfd9b30..d6d1064a7 100644 --- a/winsup/utils/locale.cc +++ b/winsup/utils/locale.cc @@ -126,9 +126,10 @@ print_locale_with_codeset (int verbose, loc_t *locale, bool utf8, if (!sysroot) { char sysbuf[PATH_MAX]; - stpcpy (stpcpy (sysbuf, getenv ("SYSTEMROOT")), - "\\system32\\kernel32.dll"); - sysroot = (const char *) cygwin_create_path (CCP_WIN_A_TO_POSIX, sysbuf); + HMODULE k32 = GetModuleHandleW (L"kernel32.dll"); + if (GetModuleFileName (k32, sysbuf, PATH_MAX)) + sysroot = (const char *) cygwin_create_path (CCP_WIN_A_TO_POSIX, + sysbuf); if (!sysroot) sysroot = "kernel32.dll"; } -- cgit v1.2.3