Skip to content

Commit

Permalink
checkkconfigsymbols.py: avoid shell injection
Browse files Browse the repository at this point in the history
Use subprocess and set shell to False to avoid potential shell
injections.

Reported-by: Bernd Dietzel <[email protected]>
Signed-off-by: Valentin Rothberg <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
vrothberg authored and gregkh committed Aug 27, 2016
1 parent 4c73c08 commit f175ba1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/checkkconfigsymbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Find Kconfig symbols that are referenced but not defined."""

# (c) 2014-2015 Valentin Rothberg <[email protected]>
# (c) 2014-2016 Valentin Rothberg <[email protected]>
# (c) 2014 Stefan Hengelein <[email protected]>
#
# Licensed under the terms of the GNU GPL License version 2
Expand All @@ -12,6 +12,7 @@
import os
import re
import signal
import subprocess
import sys
from multiprocessing import Pool, cpu_count
from optparse import OptionParser
Expand Down Expand Up @@ -222,10 +223,11 @@ def red(string):

def execute(cmd):
"""Execute %cmd and return stdout. Exit in case of error."""
pop = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True)
(stdout, _) = pop.communicate() # wait until finished
if pop.returncode != 0:
sys.exit(stdout)
try:
cmdlist = cmd.split(" ")
stdout = subprocess.check_output(cmdlist, stderr=STDOUT, shell=False)
except subprocess.CalledProcessError as fail:
exit("Failed to execute %s\n%s" % (cmd, fail))
return stdout


Expand Down

0 comments on commit f175ba1

Please sign in to comment.