diff mbox

scripts: don't source auto.conf for LOCALVERSION

Message ID 1412877423-19843-1-git-send-email-pefoley2@pefoley.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Foley Oct. 9, 2014, 5:57 p.m. UTC
setlocalversion currently sources auto.conf to get a value for
CONFIG_LOCALVERSION. This interprets auto.conf as a bash script,
causing CONFIG_LOCALVERSION="`rm -rf --no-preserve-root /`" to
actually execute the command inside the backticks
when setlocalversion is called.
While the possibility of something like this happening is remote,
use sed to avoid potential harm from untrusted .config files.

Reported-by: Fox Wilson <foxwilson123@gmail.com>
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
---
 scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 63d91e2..5b00123 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -141,7 +141,7 @@  if $scm_only; then
 fi
 
 if test -e include/config/auto.conf; then
-	. include/config/auto.conf
+	CONFIG_LOCALVERSION=$(sed -n 's/CONFIG_LOCALVERSION="\(.*\)"/\1/p' include/config/auto.conf)
 else
 	echo "Error: kernelrelease not valid - run 'make prepare' to update it"
 	exit 1