From c71f63f8993aa1194c0e8a66663aaa4a18f89a90 Mon Sep 17 00:00:00 2001 From: Corey Ashford Date: Mon, 28 Oct 2013 14:32:27 -0400 Subject: Bug 368495 - RemoteCommandLauncher#execute for RDT will fail if any environment variable's value is null Change-Id: I9b7eb1ca825a0f2e115959c15d04a1db7aec7323 Signed-off-by: Corey Ashford --- .../eclipse/ptp/rdt/core/remotemake/Messages.java | 26 ++++++++++++++++++++++ .../rdt/core/remotemake/RemoteCommandLauncher.java | 16 +++++++++++-- .../ptp/rdt/core/remotemake/messages.properties | 11 +++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/Messages.java create mode 100644 rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/messages.properties diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/Messages.java b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/Messages.java new file mode 100644 index 000000000..6509a6cff --- /dev/null +++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/Messages.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2013 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ptp.rdt.core.remotemake; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.ptp.rdt.core.remotemake.messages"; //$NON-NLS-1$ + public static String RemoteCommandLauncher_env_parse_error; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteCommandLauncher.java b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteCommandLauncher.java index 85ff50a76..640ad89f9 100644 --- a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteCommandLauncher.java +++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/RemoteCommandLauncher.java @@ -160,8 +160,20 @@ public class RemoteCommandLauncher implements ICommandLauncher { remoteEnvMap.clear(); for(String envVar : env) { - String[] splitStr = envVar.split("="); //$NON-NLS-1$ - remoteEnvMap.put(splitStr[0], splitStr[1]); + int eqIdx = envVar.indexOf('='); + if (eqIdx == -1) + throw new CoreException( + new Status( + IStatus.ERROR, + "org.eclipse.ptp.rdt.core", Messages.RemoteCommandLauncher_env_parse_error + envVar, null)); //$NON-NLS-1$ + String var = envVar.substring(0, eqIdx); + if (eqIdx == (envVar.length() - 1)) { + // The value of the variable is a null string + remoteEnvMap.put(var, null); + } else { + String val = envVar.substring(eqIdx + 1, envVar.length()); + remoteEnvMap.put(var, val); + } } // set the directory in which to run the command diff --git a/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/messages.properties b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/messages.properties new file mode 100644 index 000000000..70dacc89f --- /dev/null +++ b/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/rdt/core/remotemake/messages.properties @@ -0,0 +1,11 @@ +############################################################################### +# Copyright (c) 2012,2013 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial version +############################################################################### +RemoteCommandLauncher_env_parse_error=Error parsing environment string: -- cgit v1.2.3