Commits

Anonymous committed f1ebbc1

- Tools/faqwiz/move-faqwiz.sh: Fix unsecure use of temporary files

Comments (0)

Files changed (1)

Tools/faqwiz/move-faqwiz.sh

 #   blackjesus:~> ./move-faqwiz.sh 2\.1 3\.2
 #   Moving FAQ question 02.001 to 03.002
 
-if [ x$2 == x ]; then
+if [ x$2 = x ]; then
     echo "Need 2 args: original_version final_version."
     exit 2
 fi
     exit 2
 fi
 
-function cut_n_pad() {
+cut_n_pad() {
     t=`echo $1 | cut -d. -f $2`
     export $3=`echo $t | awk "{ tmp = \\$0; l = length(tmp); for (i = 0; i < $2-l+1; i++) { tmp = "0".tmp } print tmp  }"`
 }
 cut_n_pad $1 2 suffix1
 cut_n_pad $2 1 prefix2
 cut_n_pad $2 2 suffix2
-tmpfile=tmp$RANDOM.tmp
+if which tempfile >/dev/null; then
+    tmpfile=$(tempfile -d .)
+elif [ -n "$RANDOM" ]; then
+    tmpfile=tmp$RANDOM.tmp
+else
+    tmpfile=tmp$$.tmp
+fi
 file1=faq$prefix1.$suffix1.htp
 file2=faq$prefix2.$suffix2.htp
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.