Skip to content

Commit 21bfd41

Browse files
committed
py2lcov: Stop allowing command injection
Signed-off-by: Sebastian Pipping <[email protected]>
1 parent 170f36e commit 21bfd41

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/py2lcov

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,12 @@ Example:
191191
while os.path.exists(xml):
192192
xml = base + '.xml%d' % suffix
193193
suffix += 1
194-
cmd = "COVERAGE_FILE='%s' '%s' xml -o '%s'" % (f, args.cover_cmd, xml)
194+
env = os.environ.copy()
195+
env["COVERAGE_FILE"] = f
196+
cmd = [args.cover_cmd, "xml", "-o", xml]
195197
try:
196-
#x = subprocess.run(cmd, capture_output=True, shell=True, check=True)
197-
x = subprocess.run(cmd, shell=True, check=True, stdout=True, stderr=True)
198+
#x = subprocess.run(cmd, capture_output=True, shell=False, check=True, env=env)
199+
x = subprocess.run(cmd, shell=False, check=True, stdout=True, stderr=True, env=env)
198200
except subprocess.CalledProcessError as err:
199201
print("Error: error during XML conversion of %s: %s" % (
200202
f, str(err)));

0 commit comments

Comments
 (0)