Windows: Escaped command line arguments in subprocess.

The command line for the containerizer has the command encoded
as JSON. Non escaped quotes are removed during the containerizer
startup and the JSON processed is invalid.

Review: https://reviews.apache.org/r/47486/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7737edfe
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7737edfe
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7737edfe

Branch: refs/heads/master
Commit: 7737edfe3bd95b3b6fa09565b1ed7cb2fd1b067e
Parents: ad3e161
Author: Daniel Pravat <dpra...@outlook.com>
Authored: Mon May 30 17:55:01 2016 -0700
Committer: Joris Van Remoortere <joris.van.remoort...@gmail.com>
Committed: Mon May 30 17:55:15 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/windows/subprocess.hpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7737edfe/3rdparty/libprocess/include/process/windows/subprocess.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/windows/subprocess.hpp 
b/3rdparty/libprocess/include/process/windows/subprocess.hpp
index 551770b..8a81797 100644
--- a/3rdparty/libprocess/include/process/windows/subprocess.hpp
+++ b/3rdparty/libprocess/include/process/windows/subprocess.hpp
@@ -126,7 +126,13 @@ inline Try<PROCESS_INFORMATION> createChildProcess(
   // to have been already quoted correctly before we generate `command`.
   // Incorrectly-quoted command arguments will probably lead the child process
   // to terminate with an error. See also NOTE on `process::subprocess`.
-  const string command = strings::join(" ", argv);
+  string command = strings::join(" ", argv);
+
+  // Escape the quotes in `command`.
+  //
+  // TODO(dpravat): Add tests cases that cover this functionality. See
+  // MESOS-5418.
+  command = strings::replace(command, "\"", "\\\"");
 
   // NOTE: If Mesos is built against the ANSI version of this function, the
   // environment is limited to 32,767 characters. See[1].

Reply via email to