summaryrefslogtreecommitdiff
path: root/textproc/antiword/patches/patch-ab
blob: 58da164b2925272dab2bb0aad978354a5992f1ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$NetBSD: patch-ab,v 1.12 2006/03/09 14:50:31 ghen Exp $

Security fix for CVE-2005-3126.

--- kantiword.orig	2004-11-19 20:39:38.000000000 +0100
+++ kantiword	2006-01-23 15:14:55.000000000 +0100
@@ -10,41 +9,12 @@
 	exit 0
 fi
 
-# Determine the temp directory
-if [ -d "$TMPDIR" ] && [ -w "$TMPDIR" ]
-then
-	tmp_dir=$TMPDIR
-elif [ -d "$TEMP" ] && [ -w "$TEMP" ]
-then
-	tmp_dir=$TEMP
-else
-	tmp_dir="/tmp"
-fi                        
-
 # Try to create the temp files in a secure way
-if [ -x /bin/tempfile ]
-then
-	out_file=`/bin/tempfile -d "$tmp_dir" -p antiword -s ".ps"` || exit 1
-	err_file=`/bin/tempfile -d "$tmp_dir" -p antiword -s ".err"`
-	if [ $? -ne 0 ]
-	then
-		rm -f "$out_file"
-		exit 1
-	fi
-elif [ -x /bin/mktemp ]
-then
-	out_file=`/bin/mktemp -q -p "$tmp_dir" antiword.ps.XXXXXXXXX` || exit 1
-	err_file=`/bin/mktemp -q -p "$tmp_dir" antiword.err.XXXXXXXXX`
-	if [ $? -ne 0 ]
-	then
-		rm -f "$out_file"
-		exit 1
-	fi
-else
-	# Creating the temp files in an un-secure way
-	out_file=$tmp_dir"/antiword.$$.ps"
-	err_file=$tmp_dir"/antiword.$$.err"
-fi
+out_file=`mktemp -q -t ${0##*/}.ps.XXXXXXXXX` || \
+	{ echo "$0: Cannot create temporary file" >&2; exit 1; }
+err_file=`mktemp -q -t ${0##*/}.err.XXXXXXXXX` || \
+	{ echo "$0: Cannot create temporary file" >&2; exit 1; }
+trap "rm -f -- \"$out_file\" \"$err_file\"" 0 1 2 3 13 15
 
 # Determine the paper size
 paper_size=$1