Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marchi2017-02-06 16:53:24 -0500
committerMarc Khouzam2017-03-15 16:30:35 -0400
commit9b9bc86f2ee79e0e5c33aff58e2c7cd93b68cebd (patch)
treeee472583fa1fde0ebaa13cd62d2f5d95995cd9f3
parent4802bf3e16ee4608d0d007e9e4a460cd0cd63769 (diff)
downloadorg.eclipse.cdt-9b9bc86f2ee79e0e5c33aff58e2c7cd93b68cebd.tar.gz
org.eclipse.cdt-9b9bc86f2ee79e0e5c33aff58e2c7cd93b68cebd.tar.xz
org.eclipse.cdt-9b9bc86f2ee79e0e5c33aff58e2c7cd93b68cebd.zip
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>
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java1
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties1
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java53
3 files changed, 37 insertions, 18 deletions
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
index bd12ac948f..4ae9671d42 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
@@ -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;
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
index a9c61cb44d..ef99467f80 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
@@ -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:
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java
index 36f63c7c9f..0d8e92982d 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java
@@ -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;
+ }
+
+ /* 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;
}
- return retVal;
+
+ 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) {

Back to the top