提交 f175ba17 编写于 作者: V Valentin Rothberg 提交者: Greg Kroah-Hartman

checkkconfigsymbols.py: avoid shell injection

Use subprocess and set shell to False to avoid potential shell
injections.
Reported-by: NBernd Dietzel <tcpip@t-online.de>
Signed-off-by: NValentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 4c73c088
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"""Find Kconfig symbols that are referenced but not defined.""" """Find Kconfig symbols that are referenced but not defined."""
# (c) 2014-2015 Valentin Rothberg <valentinrothberg@gmail.com> # (c) 2014-2016 Valentin Rothberg <valentinrothberg@gmail.com>
# (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
# #
# Licensed under the terms of the GNU GPL License version 2 # Licensed under the terms of the GNU GPL License version 2
...@@ -12,6 +12,7 @@ import difflib ...@@ -12,6 +12,7 @@ import difflib
import os import os
import re import re
import signal import signal
import subprocess
import sys import sys
from multiprocessing import Pool, cpu_count from multiprocessing import Pool, cpu_count
from optparse import OptionParser from optparse import OptionParser
...@@ -222,10 +223,11 @@ def red(string): ...@@ -222,10 +223,11 @@ def red(string):
def execute(cmd): def execute(cmd):
"""Execute %cmd and return stdout. Exit in case of error.""" """Execute %cmd and return stdout. Exit in case of error."""
pop = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) try:
(stdout, _) = pop.communicate() # wait until finished cmdlist = cmd.split(" ")
if pop.returncode != 0: stdout = subprocess.check_output(cmdlist, stderr=STDOUT, shell=False)
sys.exit(stdout) except subprocess.CalledProcessError as fail:
exit("Failed to execute %s\n%s" % (cmd, fail))
return stdout return stdout
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册