diff options
author | Valentin Rothberg <valentinrothberg@gmail.com> | 2016-08-27 04:59:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-27 05:44:01 -0400 |
commit | f175ba174ef3cb8c26e828c710e4e3b0f2bbbf55 (patch) | |
tree | a328628294db949c1099a57f9317e4184fd44122 /scripts/checkkconfigsymbols.py | |
parent | 4c73c0882b34d0383ff417e2d66c127f848cfe06 (diff) |
checkkconfigsymbols.py: avoid shell injection
Use subprocess and set shell to False to avoid potential shell
injections.
Reported-by: Bernd Dietzel <tcpip@t-online.de>
Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts/checkkconfigsymbols.py')
-rwxr-xr-x | scripts/checkkconfigsymbols.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index b140fc9018b1..0cae73b5c925 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | """Find Kconfig symbols that are referenced but not defined.""" | 3 | """Find Kconfig symbols that are referenced but not defined.""" |
4 | 4 | ||
5 | # (c) 2014-2015 Valentin Rothberg <valentinrothberg@gmail.com> | 5 | # (c) 2014-2016 Valentin Rothberg <valentinrothberg@gmail.com> |
6 | # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> | 6 | # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> |
7 | # | 7 | # |
8 | # Licensed under the terms of the GNU GPL License version 2 | 8 | # Licensed under the terms of the GNU GPL License version 2 |
@@ -12,6 +12,7 @@ import difflib | |||
12 | import os | 12 | import os |
13 | import re | 13 | import re |
14 | import signal | 14 | import signal |
15 | import subprocess | ||
15 | import sys | 16 | import sys |
16 | from multiprocessing import Pool, cpu_count | 17 | from multiprocessing import Pool, cpu_count |
17 | from optparse import OptionParser | 18 | from optparse import OptionParser |
@@ -222,10 +223,11 @@ def red(string): | |||
222 | 223 | ||
223 | def execute(cmd): | 224 | def execute(cmd): |
224 | """Execute %cmd and return stdout. Exit in case of error.""" | 225 | """Execute %cmd and return stdout. Exit in case of error.""" |
225 | pop = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) | 226 | try: |
226 | (stdout, _) = pop.communicate() # wait until finished | 227 | cmdlist = cmd.split(" ") |
227 | if pop.returncode != 0: | 228 | stdout = subprocess.check_output(cmdlist, stderr=STDOUT, shell=False) |
228 | sys.exit(stdout) | 229 | except subprocess.CalledProcessError as fail: |
230 | exit("Failed to execute %s\n%s" % (cmd, fail)) | ||
229 | return stdout | 231 | return stdout |
230 | 232 | ||
231 | 233 | ||