Bug 529695 --launcher.openFile with relative path crashes
Crash is caused due to a null pointer.
program (path) is a global var. It's being read by strlen before it's
set.
eclispe.c:417:run()
-> parseArgs()
-> next = checkPath(next, getProgramDir(), 0);
checkPath() :
paths[1] = .. programDir;
buffer = malloc(.. _tcslen(paths[1])...) << strlen on a null.
But it's only set later:
eclispe.c:417:run()
-> parseArgs() << used here.
-> _run() {
-> program = _tcsdup( argv[0] ); << set here.
}
Solution is fairly trivial, just set "program" before it's used.
Verified on Linux Fedora 27. I don't see it causing issues on other
platforms, it's a very minor fix. Should probably be good to merge.
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=529695
Change-Id: I379970ecce553ef4f78a246a96ee9ac647471739
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipse.c b/features/org.eclipse.equinox.executable.feature/library/eclipse.c
index 9ab57f7..d848d03 100644
--- a/features/org.eclipse.equinox.executable.feature/library/eclipse.c
+++ b/features/org.eclipse.equinox.executable.feature/library/eclipse.c
@@ -416,6 +416,9 @@
/* vmArgs must be NULL terminated */
JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
{
+ /* arg[0] should be the full pathname of this program. */
+ program = _tcsdup( argv[0] );
+
/* Parse command line arguments (looking for the VM to use). */
/* Override configuration file arguments */
parseArgs( &argc, argv );
@@ -500,9 +503,6 @@
int launchMode;
int running = 1;
- /* arg[0] should be the full pathname of this program. */
- program = _tcsdup( argv[0] );
-
/* Initialize official program name */
officialName = name != NULL ? _tcsdup( name ) : getDefaultOfficialName();