Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c21
-rw-r--r--bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c16
2 files changed, 34 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index a657d643a..470900721 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -346,6 +346,7 @@ static const _TCHAR* getVMArch();
#ifdef _WIN32
static void createConsole();
+static void fixDLLSearchPath();
static int isConsoleLauncher();
#endif
static int consoleLauncher = 0;
@@ -406,6 +407,9 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
#elif _WIN32
/* this must be before doing any console stuff, platforms other than win32 leave this set to 0 */
consoleLauncher = isConsoleLauncher();
+
+ /*fix the DLL search path for security */
+ fixDLLSearchPath();
#endif
/* Find the directory where the Eclipse program is installed. */
@@ -1315,6 +1319,23 @@ static int isConsoleLauncher() {
}
return 0;
}
+
+static void fixDLLSearchPath() {
+#ifdef UNICODE
+ _TCHAR* functionName = _T_ECLIPSE("SetDllDirectoryW");
+#else
+ _TCHAR* functionName = _T_ECLIPSE("SetDllDirectoryA");
+#endif
+
+ BOOL (WINAPI *SetDLLDirectory)(LPCTSTR);
+ void * handle = loadLibrary(_T_ECLIPSE("Kernel32.dll"));
+ if (handle != NULL) {
+ if ( (SetDLLDirectory = findSymbol(handle, functionName)) != NULL) {
+ SetDLLDirectory(_T_ECLIPSE(""));
+ }
+ }
+}
+
#endif
/* Set the vm to use based on the given .ee file.
diff --git a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
index 8033224ae..770b464a6 100644
--- a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
+++ b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
@@ -286,6 +286,7 @@ _TCHAR * findVMLibrary( _TCHAR* command ) {
void adjustSearchPath( _TCHAR* vmLib ){
_TCHAR ** paths;
+ _TCHAR* cwd = NULL;
_TCHAR * path = NULL, *newPath = NULL;
_TCHAR * c;
int i, length;
@@ -293,12 +294,20 @@ void adjustSearchPath( _TCHAR* vmLib ){
paths = getVMLibrarySearchPath(vmLib);
+ /* bug 325902 - add current working dir to the end of the search path */
+ length = GetCurrentDirectory(0, NULL);
+ cwd = malloc((length + 1)* sizeof(_TCHAR));
+ GetCurrentDirectory(length, cwd);
+ cwd[length - 1] = pathSeparator;
+ cwd[length] = 0;
+
/* first call to GetEnvironmentVariable tells us how big to make the buffer */
length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0);
if (length > 0) {
+ _TCHAR* current [] = { cwd, NULL };
path = malloc(length * sizeof(_TCHAR));
GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length);
- needAdjust = !containsPaths(path, paths);
+ needAdjust = !containsPaths(path, paths) || !containsPaths(path, current);
freePath = 1;
} else {
path = _T_ECLIPSE("");
@@ -308,8 +317,8 @@ void adjustSearchPath( _TCHAR* vmLib ){
if (needAdjust) {
c = concatStrings(paths);
- newPath = malloc((_tcslen(c) + length + 1) * sizeof(_TCHAR));
- _stprintf(newPath, _T_ECLIPSE("%s%s"), c, path);
+ newPath = malloc((_tcslen(c) + length + 1 + _tcslen(cwd) + 1) * sizeof(_TCHAR));
+ _stprintf(newPath, _T_ECLIPSE("%s%s%c%s"), c, path, pathSeparator, cwd);
SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath);
free(c);
free(newPath);
@@ -318,6 +327,7 @@ void adjustSearchPath( _TCHAR* vmLib ){
for (i = 0; paths[i] != NULL; i++)
free(paths[i]);
free(paths);
+ free(cwd);
if (freePath)
free(path);
}

Back to the top