git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-sh-setup.sh: fix missing double quotes variables
@ 2016-06-18 19:37 LE Manh Cuong
  2016-06-18 20:12 ` LE Manh Cuong
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: LE Manh Cuong @ 2016-06-18 19:37 UTC (permalink / raw)
  To: git; +Cc: LE Manh Cuong

Leaving shell variables un-quotes can lead to security vulnerabilities. In:

    : ${x=.}

`$x` is always expanded, cause `glob+split` on its result. There're some
globs is too expensive to expand, like:

    x='/*/*/*/*/../../../../*/*/*/*/../../../../*/*/*/*' sh -c ':
    ${x=.}'

Run it and our machine will hang/crash (especially in Linux).

`LESS`, `LV` and `GIT_OBJECT_DIRECTORY` variables in `git-sh-setup` are
vulnerable with this case.

Fix this vulnerability  by quoting those variables.

Signed-off-by: LE Manh Cuong <cuong.manhle.vn@gmail.com>
---
 git-sh-setup.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index c48139a..85db5f1 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -160,8 +160,8 @@ git_pager() {
 	else
 		GIT_PAGER=cat
 	fi
-	: ${LESS=-FRX}
-	: ${LV=-c}
+	: "${LESS=-FRX}"
+	: "${LV=-c}"
 	export LESS LV
 
 	eval "$GIT_PAGER" '"$@"'
@@ -344,7 +344,7 @@ git_dir_init () {
 		echo >&2 "Unable to determine absolute path of git directory"
 		exit 1
 	}
-	: ${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}
+	: "${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}"
 }
 
 if test -z "$NONGIT_OK"
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-06-19 21:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-18 19:37 [PATCH] git-sh-setup.sh: fix missing double quotes variables LE Manh Cuong
2016-06-18 20:12 ` LE Manh Cuong
2016-06-18 20:26 ` [PATCH] git-sh-setup.sh: fix missing double quotes variables LE Manh Cuong
2016-06-19  1:43 ` Junio C Hamano
2016-06-19  2:45   ` LE Manh Cuong
2016-06-19  3:16     ` Junio C Hamano
2016-06-19 11:31       ` LE Manh Cuong
2016-06-19 17:59       ` Junio C Hamano
2016-06-19 18:09         ` LE Manh Cuong
2016-06-19 21:06           ` Junio C Hamano
2016-06-19 21:18             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).