aboutsummaryrefslogtreecommitdiff
path: root/comms/mgetty+sendfax/files/patch-CVE-2008-4936
blob: b3ce58f7a0543474b1da5bc5918b2640f5bd0952 (plain) (blame)
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
--- fax/faxspool.in.orig	2008-12-06 22:30:36.000000000 +0300
+++ fax/faxspool.in	2008-12-06 22:48:40.000000000 +0300
@@ -653,12 +653,12 @@
 #
 # mkdir a directory in $TMP (or /tmp), convert input to G3 in there
 #
-spooldir=${TMP:-/tmp}/$new_seq.$$.`date +%S`
+spooldir=`mktemp -d "${TMP:-/tmp}"/"$new_seq.$$".XXXXXXXX`
 
-if ( umask 077 ; mkdir $spooldir ) ; then
+if [ $? -eq 0 ]; then
     $echo "spooling to $spooldir (->$new_seq)..."
 else
-    $echo "ERROR: can't create work dir '$spooldir', giving up" >&2 ; exit 6
+    $echo "ERROR: can't create work dir inside '${TMP:-/tmp}', giving up" >&2 ; exit 6
 fi
 
 #
@@ -675,9 +675,12 @@
     if [ x$file = x- ]
     then
 	$echo "spooling $file (stdin)..."
-	trap "rm /tmp/faxsp.$$" 0
-        cat - >/tmp/faxsp.$$
-	file=/tmp/faxsp.$$
+	file=`mktemp "$spooldir/faxsp.XXXXXXXX"`
+	if [ -z "$file" ]; then
+		$echo "ERROR: can't create work file, giving up" >&2; exit 6
+	fi
+	trap "rm -f $file" 0
+        cat - >"$file"
     else
 	$echo "spooling $file..."
     fi
@@ -924,7 +927,7 @@
 then
     $echo "\nnothing to do (no cover page, no data)." >&2
     cd $FAX_SPOOL_OUT
-    rmdir $spooldir
+    rm -rf $spooldir
     exit 52
 fi
 
@@ -965,7 +968,7 @@
 # clean up
 rm $job.q
 cd ..
-rmdir $spooldir
+rm -rf $spooldir
 
 if [ -z "`find $LAST_RUN -ctime -1 -print 2>/dev/null`" ]
 then