[jbosstools-issues] [JBoss JIRA] (JBIDE-23862) Server adapter: if "oc" in preferences is set to path with a " " syncing fails

Dmitrii Bocharov (JIRA) issues at jboss.org
Fri May 12 09:21:00 EDT 2017


    [ https://issues.jboss.org/browse/JBIDE-23862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13405676#comment-13405676 ] 

Dmitrii Bocharov commented on JBIDE-23862:
------------------------------------------

And i see why it works. Java guys seem to have lots of problem to run it correctly. Look at the source code (pay attention to comments) of the _java.lang.ProcessImpl.ProcessImpl(String[], String, String, long[], boolean)_:

{code:java}
 if (allowAmbiguousCommands) {
            // Legacy mode.

            // Normalize path if possible.
            String executablePath = new File(cmd[0]).getPath();

            // No worry about internal, unpaired ["], and redirection/piping.
            if (needsEscaping(VERIFICATION_LEGACY, executablePath) )
                executablePath = quoteString(executablePath);

            cmdstr = createCommandLine(
                //legacy mode doesn't worry about extended verification
                VERIFICATION_LEGACY,
                executablePath,
                cmd);
        } else {
            String executablePath;
            try {
                executablePath = getExecutablePath(cmd[0]);
            } catch (IllegalArgumentException e) {
                // Workaround for the calls like
                // Runtime.getRuntime().exec("\"C:\\Program Files\\foo\" bar")

                // No chance to avoid CMD/BAT injection, except to do the work
                // right from the beginning. Otherwise we have too many corner
                // cases from
                //    Runtime.getRuntime().exec(String[] cmd [, ...])
                // calls with internal ["] and escape sequences.

                // Restore original command line.
                StringBuilder join = new StringBuilder();
                // terminal space in command line is ok
                for (String s : cmd)
                    join.append(s).append(' ');

                // Parse the command line again.
                cmd = getTokensFromCommand(join.toString());
                executablePath = getExecutablePath(cmd[0]);

                // Check new executable name once more
                if (security != null)
                    security.checkExec(executablePath);
            }
{code}



> Server adapter: if "oc" in preferences is set to path with a " " syncing fails
> ------------------------------------------------------------------------------
>
>                 Key: JBIDE-23862
>                 URL: https://issues.jboss.org/browse/JBIDE-23862
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: openshift
>    Affects Versions: 4.4.3.Final
>            Reporter: Andre Dietisheim
>            Assignee: Andre Dietisheim
>             Fix For: 4.5.0.AM1
>
>         Attachments: ProcessMain.java
>
>




--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jbosstools-issues mailing list