Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2011-03-18 19:05:38 +0000
committerAndrew Niefer2011-03-18 19:05:38 +0000
commit699d7e52fe788a64475e66342d27d39f2a090ab9 (patch)
tree751d828df8e346ddc9915eb775e0b35c0cbbe4a5
parentc4e0c6db2fcd3baeeb69cbd67fac0a9119045f4c (diff)
downloadrt.equinox.framework-699d7e52fe788a64475e66342d27d39f2a090ab9.tar.gz
rt.equinox.framework-699d7e52fe788a64475e66342d27d39f2a090ab9.tar.xz
rt.equinox.framework-699d7e52fe788a64475e66342d27d39f2a090ab9.zip
bug 337715 - segfault on empty path component
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseCommon.c4
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseMain.c17
2 files changed, 14 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c b/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
index 56c1a7151..cdfb0fba1 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
@@ -276,8 +276,8 @@ _TCHAR* findSymlinkCommand( _TCHAR* command, int resolve )
}
#endif
/* Determine if the executable resides in this directory. */
- if (cmdPath[0] == _T_ECLIPSE('.') &&
- (_tcslen(cmdPath) == 1 || (_tcslen(cmdPath) == 2 && IS_DIR_SEPARATOR(cmdPath[1]))))
+ if (_tcslen(cmdPath) == 0 || /*an empty path entry is treated as '.' */
+ (cmdPath[0] == _T_ECLIPSE('.') && (_tcslen(cmdPath) == 1 || (_tcslen(cmdPath) == 2 && IS_DIR_SEPARATOR(cmdPath[1])))))
{
_tgetcwd( cmdPath, MAX_PATH_LENGTH );
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseMain.c b/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
index 657252e02..3cd2697cc 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
@@ -14,6 +14,11 @@
#include "eclipseCommon.h"
#include "eclipseConfig.h"
+#ifdef _WIN32
+#include <direct.h>
+#else
+#include <unistd.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -52,6 +57,7 @@ static _TCHAR* getDefaultOfficialName(_TCHAR* program);
static _TCHAR* findProgram(_TCHAR* argv[]);
static _TCHAR* findLibrary(_TCHAR* library, _TCHAR* program);
static _TCHAR* checkForIni(int argc, _TCHAR* argv[]);
+static _TCHAR* getDirFromProgram(_TCHAR* program);
static int initialArgc;
static _TCHAR** initialArgv;
@@ -153,7 +159,7 @@ int main( int argc, _TCHAR* argv[] )
officialName = name != NULL ? _tcsdup( name ) : getDefaultOfficialName(program);
/* Find the directory where the Eclipse program is installed. */
- programDir = getProgramDir(program);
+ programDir = getDirFromProgram(program);
/* Find the eclipse library */
eclipseLibrary = findLibrary(eclipseLibrary, program);
@@ -313,7 +319,7 @@ static int createUserArgs(int configArgc, _TCHAR **configArgv, int *argc, _TCHAR
* This function takes the directory where program executable resides and
* determines the installation directory.
*/
-_TCHAR* getProgramDir(_TCHAR* program)
+_TCHAR* getDirFromProgram(_TCHAR* program)
{
_TCHAR* ch;
@@ -329,10 +335,11 @@ _TCHAR* getProgramDir(_TCHAR* program)
return programDir;
}
- /* Can't figure out from the program */
+ /* Can't figure out from the program, lets use the cwd */
free(programDir);
- programDir = NULL;
- return NULL;
+ programDir = malloc( MAX_PATH_LENGTH * sizeof (_TCHAR));
+ _tgetcwd( programDir, MAX_PATH_LENGTH );
+ return programDir;
}
_TCHAR* getOfficialName() {

Back to the top