mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 511801 - Remote launch: validate that the remote exec file is absolute
From my experience, bad things happen if the user specifies a non-absolute path in the box labeled "Remote Absolute File Path for C/C++ Application". This patch adds a validation to the tab to make sure that the path is a valid absolute POSIX path. This assumes that we do not support remote launching on Windows targets, and therefore do not need to specify paths such as "C:\foo\bar.exe". Change-Id: I20367078ff20179f0515272afee17d0986940309 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
parent
4802bf3e16
commit
9b9bc86f2e
3 changed files with 37 additions and 18 deletions
|
@ -40,6 +40,7 @@ public class Messages extends NLS {
|
||||||
public static String RemoteCMainTab_Remote_Path_Browse_Button_Title;
|
public static String RemoteCMainTab_Remote_Path_Browse_Button_Title;
|
||||||
public static String RemoteCMainTab_SkipDownload;
|
public static String RemoteCMainTab_SkipDownload;
|
||||||
public static String RemoteCMainTab_ErrorNoProgram;
|
public static String RemoteCMainTab_ErrorNoProgram;
|
||||||
|
public static String RemoteCMainTab_ErrorRemoteProgNotAbsolute;
|
||||||
public static String RemoteCMainTab_ErrorNoConnection;
|
public static String RemoteCMainTab_ErrorNoConnection;
|
||||||
public static String RemoteCMainTab_Connection;
|
public static String RemoteCMainTab_Connection;
|
||||||
public static String RemoteCMainTab_New;
|
public static String RemoteCMainTab_New;
|
||||||
|
|
|
@ -39,6 +39,7 @@ RemoteCMainTab_Program=Remote Absolute File Path for C/C++ Application:
|
||||||
RemoteCMainTab_SkipDownload=Skip download to target path.
|
RemoteCMainTab_SkipDownload=Skip download to target path.
|
||||||
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
|
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
|
||||||
RemoteCMainTab_ErrorNoProgram=Remote executable path is not specified.
|
RemoteCMainTab_ErrorNoProgram=Remote executable path is not specified.
|
||||||
|
RemoteCMainTab_ErrorRemoteProgNotAbsolute=Remote executable path is not absolute.
|
||||||
RemoteCMainTab_ErrorNoConnection=Remote Connection must be selected.
|
RemoteCMainTab_ErrorNoConnection=Remote Connection must be selected.
|
||||||
RemoteCMainTab_Remote_Path_Browse_Button=Browse...
|
RemoteCMainTab_Remote_Path_Browse_Button=Browse...
|
||||||
RemoteCMainTab_Connection=Connection:
|
RemoteCMainTab_Connection=Connection:
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class RemoteCDSFMainTab extends CMainTab {
|
||||||
private static final String REMOTE_PROG_LABEL_TEXT = Messages.RemoteCMainTab_Program;
|
private static final String REMOTE_PROG_LABEL_TEXT = Messages.RemoteCMainTab_Program;
|
||||||
private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
|
private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
|
||||||
private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
|
private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
|
||||||
|
private static final String REMOTE_PROG_NOT_ABSOLUTE = Messages.RemoteCMainTab_ErrorRemoteProgNotAbsolute;
|
||||||
private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
|
private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
|
||||||
private static final String PRE_RUN_LABEL_TEXT = Messages.RemoteCMainTab_Prerun;
|
private static final String PRE_RUN_LABEL_TEXT = Messages.RemoteCMainTab_Prerun;
|
||||||
|
|
||||||
|
@ -132,25 +133,41 @@ public class RemoteCDSFMainTab extends CMainTab {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(ILaunchConfiguration config) {
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
boolean retVal = super.isValid(config);
|
if (!super.isValid(config)) {
|
||||||
if (retVal == true) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear any pre-existing message. */
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
|
|
||||||
|
/* Verify that a remote connection is selected. */
|
||||||
int currentSelection = connectionCombo.getSelectionIndex();
|
int currentSelection = connectionCombo.getSelectionIndex();
|
||||||
String connection_name = currentSelection >= 0 ? connectionCombo
|
if (currentSelection < 0) {
|
||||||
.getItem(currentSelection) : ""; //$NON-NLS-1$
|
setErrorMessage(CONNECTION_TEXT_ERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String connection_name = connectionCombo.getItem(currentSelection);
|
||||||
if (connection_name.isEmpty()) {
|
if (connection_name.isEmpty()) {
|
||||||
setErrorMessage(CONNECTION_TEXT_ERROR);
|
setErrorMessage(CONNECTION_TEXT_ERROR);
|
||||||
retVal = false;
|
return false;
|
||||||
}
|
}
|
||||||
if (retVal) {
|
|
||||||
String name = remoteProgText.getText().trim();
|
/* Verify that the remote executable file name is specified. */
|
||||||
if (name.length() == 0) {
|
String remoteProgName = remoteProgText.getText().trim();
|
||||||
|
if (remoteProgName.isEmpty()) {
|
||||||
setErrorMessage(REMOTE_PROG_TEXT_ERROR);
|
setErrorMessage(REMOTE_PROG_TEXT_ERROR);
|
||||||
retVal = false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Verify that the remote executable file name is absolute. */
|
||||||
|
Path remoteProgPath = Path.forPosix(remoteProgName);
|
||||||
|
if (!remoteProgPath.isAbsolute()) {
|
||||||
|
setErrorMessage(REMOTE_PROG_NOT_ABSOLUTE);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return retVal;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createRemoteConnectionGroup(Composite parent, int colSpan) {
|
protected void createRemoteConnectionGroup(Composite parent, int colSpan) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue