mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +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_SkipDownload;
|
||||
public static String RemoteCMainTab_ErrorNoProgram;
|
||||
public static String RemoteCMainTab_ErrorRemoteProgNotAbsolute;
|
||||
public static String RemoteCMainTab_ErrorNoConnection;
|
||||
public static String RemoteCMainTab_Connection;
|
||||
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.
|
||||
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
|
||||
RemoteCMainTab_ErrorNoProgram=Remote executable path is not specified.
|
||||
RemoteCMainTab_ErrorRemoteProgNotAbsolute=Remote executable path is not absolute.
|
||||
RemoteCMainTab_ErrorNoConnection=Remote Connection must be selected.
|
||||
RemoteCMainTab_Remote_Path_Browse_Button=Browse...
|
||||
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 SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
|
||||
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 PRE_RUN_LABEL_TEXT = Messages.RemoteCMainTab_Prerun;
|
||||
|
||||
|
@ -132,25 +133,41 @@ public class RemoteCDSFMainTab extends CMainTab {
|
|||
*/
|
||||
@Override
|
||||
public boolean isValid(ILaunchConfiguration config) {
|
||||
boolean retVal = super.isValid(config);
|
||||
if (retVal == true) {
|
||||
setErrorMessage(null);
|
||||
int currentSelection = connectionCombo.getSelectionIndex();
|
||||
String connection_name = currentSelection >= 0 ? connectionCombo
|
||||
.getItem(currentSelection) : ""; //$NON-NLS-1$
|
||||
if (connection_name.isEmpty()) {
|
||||
setErrorMessage(CONNECTION_TEXT_ERROR);
|
||||
retVal = false;
|
||||
}
|
||||
if (retVal) {
|
||||
String name = remoteProgText.getText().trim();
|
||||
if (name.length() == 0) {
|
||||
setErrorMessage(REMOTE_PROG_TEXT_ERROR);
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
if (!super.isValid(config)) {
|
||||
return false;
|
||||
}
|
||||
return retVal;
|
||||
|
||||
/* Clear any pre-existing message. */
|
||||
setErrorMessage(null);
|
||||
|
||||
/* Verify that a remote connection is selected. */
|
||||
int currentSelection = connectionCombo.getSelectionIndex();
|
||||
if (currentSelection < 0) {
|
||||
setErrorMessage(CONNECTION_TEXT_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
String connection_name = connectionCombo.getItem(currentSelection);
|
||||
if (connection_name.isEmpty()) {
|
||||
setErrorMessage(CONNECTION_TEXT_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Verify that the remote executable file name is specified. */
|
||||
String remoteProgName = remoteProgText.getText().trim();
|
||||
if (remoteProgName.isEmpty()) {
|
||||
setErrorMessage(REMOTE_PROG_TEXT_ERROR);
|
||||
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 true;
|
||||
}
|
||||
|
||||
protected void createRemoteConnectionGroup(Composite parent, int colSpan) {
|
||||
|
|
Loading…
Add table
Reference in a new issue