Skip to content

Commit

Permalink
miniprohex: Fix temporary file handling
Browse files Browse the repository at this point in the history
Avoid insecure temporary file and drop it after use.
  • Loading branch information
lkundrak committed Oct 7, 2014
1 parent 1b451ae commit 34a8186
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions miniprohex
Expand Up @@ -30,10 +30,8 @@ RWOPT=
FN=
# Extension provided
EXT=
# Options for srec_copy
# Options for srec_cat
SRECOPTS=
# Place to put stuff
TMPDIR=/tmp

# parse arguments and sort them out
while [ $# != 0 ]
Expand Down Expand Up @@ -97,12 +95,12 @@ PRECVT=
POSTCVT=
;;
hex)
RFILE="$TMPDIR/$$.bin"
RFILE="$(mktemp)"
PRECVT="srec_cat $FN --intel -o $SRECOPT $RFILE --binary"
POSTCVT="srec_cat $RFILE --binary $SRECOPTS -o $FN --intel"
;;
srec)
RFILE=$TMPDIR/$$.bin
RFILE="$(mktemp)"
PRECVT="srec_cat $FN --motorola -o $SRECOPT $RFILE --binary"
POSTCVT="srec_cat $RFILE --binary $SRECOPTS -o $FN --motorola"
;;
Expand All @@ -129,6 +127,5 @@ minipro $OPTS $RWOPT $RFILE
$POSTCVT
fi




# Purge the temporary file if we used one
[ "$PRECVT" ] && rm "$RFILE"

0 comments on commit 34a8186

Please sign in to comment.