From 1d7d4c2446c85736680b24a2952619dba665bf6e Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Wed, 4 Sep 2019 20:36:20 +0800 Subject: [PATCH] Switch from using /tmp to using mktemp mktemp protects against attacks from other users. mktemp protects against concurrent writers. mktemp respects the $TMPDIR environment variable. Suggested-by: check-all-the-things --- bin/git-create-branch | 7 ++++--- install.sh | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/git-create-branch b/bin/git-create-branch index c94d0a0..c0d1dd4 100755 --- a/bin/git-create-branch +++ b/bin/git-create-branch @@ -37,10 +37,11 @@ test -z $BRANCH && echo "branch argument required." 1>&2 && exit 1 if [[ -n $REMOTE ]] then - git ls-remote --exit-code $REMOTE 1>/dev/null 2>/tmp/ls-remote-error + stderr=$(git_extra_mktemp) + git ls-remote --exit-code $REMOTE 1>/dev/null 2>"$stderr" REMOTE_EXIT=$? - REMOTE_ERROR=$( /dev/null \ && cd git-extras \ && git checkout \ $(git describe --tags $(git rev-list --tags --max-count=1)) \ &> /dev/null \ - && make_install + && make_install \ + && rm -rf "$dir"