Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342748 - [launcher] Crash in formatVmCommandMsg
Summary: [launcher] Crash in formatVmCommandMsg
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 3.4.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 critical (vote)
Target Milestone: 3.4.2+   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 315939
Blocks: 317200 322291
  Show dependency tree
 
Reported: 2011-04-13 13:52 EDT by Andrew Niefer CLA
Modified: 2011-04-13 15:56 EDT (History)
5 users (show)

See Also:


Attachments
Patch (1.18 KB, patch)
2011-04-13 14:08 EDT, Andrew Niefer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Niefer CLA 2011-04-13 13:52:02 EDT
+++ This bug was initially created as a clone of Bug #315939 +++

Build Identifier: 3.4.2

In formatVmCommandMsg, there is code to format the message. There is a potential problem in "if (list[index][0] == _T_ECLIPSE('-') && *(ch-1) == _T_ECLIPSE(' '))"  .  "*(ch-1)" may point to an address that is outside the message memory range.  The fix is to change the line to "if (list[index][0] == _T_ECLIPSE('-') && ch != message && *(ch-1) == _T_ECLIPSE(' ')) , this avoids the bad access crash. 

I am trying to create a patch but the network is very slow here today. Since this is a one line fix, so I choose to directly describe here. 


	message = malloc( (length + 5) * sizeof(_TCHAR) );

	/* Format the message such that options (args starting with '-') begin
	   on a new line. Otherwise, the Motif MessageBox does not automatically wrap
	   the messages and the message window can extend beyond both sides of the display. */
	ch = message;
	if(args != NULL) list = args;
	else             list = vmArgs;
	while(list != NULL) {
		for (index = 0; list[index] != NULL; index++)
		{
			if (list[index][0] == _T_ECLIPSE('-') && *(ch-1) == _T_ECLIPSE(' '))
				*(ch-1) = _T_ECLIPSE('\n');
			_tcscpy( ch, list[index] );
			ch += _tcslen( list[index] );
			*ch++ = _T_ECLIPSE(' ');
		}
		if(list == vmArgs) list = progArgs;
		else 			   list = NULL;
	}
	*ch = _T_ECLIPSE('\0');

Reproducible: Always
Comment 1 Andrew Niefer CLA 2011-04-13 14:08:01 EDT
Created attachment 193180 [details]
Patch

Patch from Bug 315939 recreated for 3.4.2
Comment 2 Andrew Niefer CLA 2011-04-13 15:56:17 EDT
Patch and recompiled binaries released to branch R3_4_maintenance