Skip to content

Commit

Permalink
Merge pull request #4 from lucaskanashiro/insecure_tmp
Browse files Browse the repository at this point in the history
Use mktemp to create temporary directory and files
  • Loading branch information
MaG21 committed Dec 24, 2022
2 parents 735a6c1 + 9412e8b commit 3a02d9e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ done
###

AW_PATH=$HOME/.vim-anywhere
TMPFILE_DIR=/tmp/vim-anywhere
TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S")
TMPFILE_DIR="$(mktemp -d /tmp/vim-anywhere.XXX)"
TMPFILE_TEMPLATE=doc-$(date +"%y%m%d%H%M%S").XXX
VIM_OPTS=--nofork

# Use ~/.gvimrc.min or ~/.vimrc.min if one exists
Expand All @@ -53,8 +53,14 @@ for vimrc_path in "${VIMRC_PATH[@]}"; do
fi
done

mkdir -p $TMPFILE_DIR
touch $TMPFILE
TMPFILE="$(mktemp -p $TMPFILE_DIR -t $TMPFILE_TEMPLATE)"

function remove_tmp_dir() {
rm -rf $TMPFILE_DIR
}

## Removes all temp files on exit and sigint
trap "remove_tmp_dir" EXIT SIGINT

# Linux
if [[ $OSTYPE == "linux-gnu" ]]; then
Expand Down

0 comments on commit 3a02d9e

Please sign in to comment.