From: Valentin Rothberg <valentinrothberg@gmail.com>
To: gregkh@linuxfoundation.org, tcpip@t-online.de
Cc: linux-kernel@vger.kernel.org,
Valentin Rothberg <valentinrothberg@gmail.com>
Subject: [PATCH] checkkconfigsymbols.py: avoid shell injection
Date: Sat, 27 Aug 2016 10:59:07 +0200 [thread overview]
Message-ID: <20160827085907.61796-1-valentinrothberg@gmail.com> (raw)
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>
---
Note that I don't see how it could be exploited currently. There is no
user input used in the execute() function. I see the patch more as a
preventive fix than something urgent.
scripts/checkkconfigsymbols.py | 12 +++++++-----
1 file 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 @@
"""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>
#
# Licensed under the terms of the GNU GPL License version 2
@@ -12,6 +12,7 @@ import difflib
import os
import re
import signal
+import subprocess
import sys
from multiprocessing import Pool, cpu_count
from optparse import OptionParser
@@ -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
--
2.9.3
reply other threads:[~2016-08-27 9:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160827085907.61796-1-valentinrothberg@gmail.com \
--to=valentinrothberg@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tcpip@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®