[libc++] Use proper shell escaping in the executors
authorLouis Dionne <ldionne@apple.com>
Fri, 17 Apr 2020 20:43:35 +0000 (16:43 -0400)
committerLouis Dionne <ldionne@apple.com>
Fri, 17 Apr 2020 20:46:43 +0000 (16:46 -0400)
libcxx/utils/run.py
libcxx/utils/ssh.py

index 7cdf652..e9f9859 100644 (file)
@@ -14,6 +14,7 @@ program's error code.
 
 import argparse
 import os
+import pipes
 import shutil
 import subprocess
 import sys
@@ -57,8 +58,9 @@ def main():
             else:
                 shutil.copy2(dep, args.execdir)
 
-        # Run the executable with the given environment in the execution directory.
-        return subprocess.call(' '.join(remaining), cwd=args.execdir, env=env, shell=True)
+        # Run the command line with the given environment in the execution directory.
+        commandLine = (pipes.quote(x) for x in remaining)
+        return subprocess.call(' '.join(commandLine), cwd=args.execdir, env=env, shell=True)
     finally:
         shutil.rmtree(args.execdir)
 
index c7d8c97..f9bcabe 100644 (file)
@@ -15,6 +15,7 @@ conformance test suite.
 
 import argparse
 import os
+import pipes
 import posixpath
 import subprocess
 import sys
@@ -97,10 +98,11 @@ def main():
         # host by transforming the path of test-executables to their path in the
         # temporary directory, where we know they have been copied when we handled
         # test dependencies above.
+        commandLine = (pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
         remoteCommands += [
             'cd {}'.format(tmp),
             'export {}'.format(' '.join(args.env)),
-            ' '.join(pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
+            ' '.join(pipes.quote(x) for x in commandLine)
         ]
 
         # Finally, SSH to the remote host and execute all the commands.