summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2016-01-11 18:46:01 +0100
committerCorinna Vinschen <corinna@vinschen.de>2016-01-11 18:46:01 +0100
commitb4cf3f454d8c2a05d6956fbc1eae3942d2f1730a (patch)
treeafc06660a2e93e10883927ad8ba03aac7d646141
parenta10d96923188977446ebd84323b47f7085fb5cb4 (diff)
downloadcygnal-b4cf3f454d8c2a05d6956fbc1eae3942d2f1730a.tar.gz
cygnal-b4cf3f454d8c2a05d6956fbc1eae3942d2f1730a.tar.bz2
cygnal-b4cf3f454d8c2a05d6956fbc1eae3942d2f1730a.zip
Revert "autoload.cc: Drop using full paths for system DLLs"
This reverts commit 4b104ce07070e32363a217a554441a8b4df69d12. The DLLs always guaranteed to be loaded from the system dir are only those in the KnownDLLs list. We're using some DLLs not in that list on all supported OSes, thus we need to make sure to use full paths. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/autoload.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index e14647c2d..836597da8 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -420,15 +420,18 @@ std_dll_init ()
{
fenv_t fpuenv;
fegetenv (&fpuenv);
+ WCHAR dll_path[MAX_PATH];
DWORD err = ERROR_SUCCESS;
int i;
+ /* http://www.microsoft.com/technet/security/advisory/2269637.mspx */
+ wcpcpy (wcpcpy (dll_path, windows_system_directory), dll->name);
/* MSDN seems to imply that LoadLibrary can fail mysteriously, so,
since there have been reports of this in the mailing list, retry
several times before giving up. */
for (i = 1; i <= RETRY_COUNT; i++)
{
/* If loading the library succeeds, just leave the loop. */
- if (dll_load (dll->handle, dll->name))
+ if (dll_load (dll->handle, dll_path))
break;
/* Otherwise check error code returned by LoadLibrary. If the
error code is neither NOACCESS nor DLL_INIT_FAILED, break out
@@ -441,10 +444,15 @@ std_dll_init ()
}
if ((uintptr_t) dll->handle <= 1)
{
- if ((func->decoration & 1))
+ /* If LoadLibrary with full path returns one of the weird errors
+ reported on the Cygwin mailing list, retry with only the DLL
+ name. Only do this when the above retry loop has been exhausted. */
+ if (i > RETRY_COUNT && dll_load (dll->handle, dll->name))
+ /* got it with the fallback */;
+ else if ((func->decoration & 1))
dll->handle = INVALID_HANDLE_VALUE;
else
- api_fatal ("unable to load %W, %E", dll->name);
+ api_fatal ("unable to load %W, %E", dll_path);
}
fesetenv (&fpuenv);
}