Skip to content

Commit f8452dd

Browse files
committed
[libc++] Use proper shell escaping in the executors
1 parent 701af68 commit f8452dd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libcxx/utils/run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import argparse
1616
import os
17+
import pipes
1718
import shutil
1819
import subprocess
1920
import sys
@@ -57,8 +58,9 @@ def main():
5758
else:
5859
shutil.copy2(dep, args.execdir)
5960

60-
# Run the executable with the given environment in the execution directory.
61-
return subprocess.call(' '.join(remaining), cwd=args.execdir, env=env, shell=True)
61+
# Run the command line with the given environment in the execution directory.
62+
commandLine = (pipes.quote(x) for x in remaining)
63+
return subprocess.call(' '.join(commandLine), cwd=args.execdir, env=env, shell=True)
6264
finally:
6365
shutil.rmtree(args.execdir)
6466

libcxx/utils/ssh.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import argparse
1717
import os
18+
import pipes
1819
import posixpath
1920
import subprocess
2021
import sys
@@ -97,10 +98,11 @@ def main():
9798
# host by transforming the path of test-executables to their path in the
9899
# temporary directory, where we know they have been copied when we handled
99100
# test dependencies above.
101+
commandLine = (pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
100102
remoteCommands += [
101103
'cd {}'.format(tmp),
102104
'export {}'.format(' '.join(args.env)),
103-
' '.join(pathOnRemote(x) if isTestExe(x) else x for x in commandLine)
105+
' '.join(pipes.quote(x) for x in commandLine)
104106
]
105107

106108
# Finally, SSH to the remote host and execute all the commands.

0 commit comments

Comments
 (0)