Skip to content

Commit aec20a6

Browse files
committed
- Tools/faqwiz/move-faqwiz.sh: Fix unsecure use of temporary files.
1 parent a5f3ceb commit aec20a6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Misc/NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ Tests
5555
Build
5656
-----
5757

58+
Tools/Demos
59+
-----------
60+
61+
- Tools/faqwiz/move-faqwiz.sh: Fix unsecure use of temporary files.
62+
5863
What's New in Python 2.4.5?
5964
=============================
6065

Tools/faqwiz/move-faqwiz.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# blackjesus:~> ./move-faqwiz.sh 2\.1 3\.2
1010
# Moving FAQ question 02.001 to 03.002
1111

12-
if [ x$2 == x ]; then
12+
if [ x$2 = x ]; then
1313
echo "Need 2 args: original_version final_version."
1414
exit 2
1515
fi
@@ -19,7 +19,7 @@ if [ ! -d data -o ! -d data/RCS ]; then
1919
exit 2
2020
fi
2121

22-
function cut_n_pad() {
22+
cut_n_pad() {
2323
t=`echo $1 | cut -d. -f $2`
2424
export $3=`echo $t | awk "{ tmp = \\$0; l = length(tmp); for (i = 0; i < $2-l+1; i++) { tmp = "0".tmp } print tmp }"`
2525
}
@@ -28,7 +28,13 @@ cut_n_pad $1 1 prefix1
2828
cut_n_pad $1 2 suffix1
2929
cut_n_pad $2 1 prefix2
3030
cut_n_pad $2 2 suffix2
31-
tmpfile=tmp$RANDOM.tmp
31+
if which tempfile >/dev/null; then
32+
tmpfile=$(tempfile -d .)
33+
elif [ -n "$RANDOM" ]; then
34+
tmpfile=tmp$RANDOM.tmp
35+
else
36+
tmpfile=tmp$$.tmp
37+
fi
3238
file1=faq$prefix1.$suffix1.htp
3339
file2=faq$prefix2.$suffix2.htp
3440

0 commit comments

Comments
 (0)