Blame SOURCES/0003-various-security-fixes.patch

ce9878
From 36115e102859badb08cb5b2398de6b0ba45421d3 Mon Sep 17 00:00:00 2001
ce9878
From: Jan Vcelak <jvcelak@redhat.com>
ce9878
Date: Tue, 4 Nov 2014 14:36:47 +0100
ce9878
Subject: [PATCH] various security fixes
ce9878
ce9878
CVE-2009-5044 (#709413)
ce9878
CVE-2009-5080 (#720058)
ce9878
CVE-2009-5081 (#720057)
ce9878
ce9878
Based on: http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/groff/groff-1.20.1-owl-tmp.diff?rev=1.2;content-type=text%2Fplain
ce9878
Resolves: #709415, #720060
ce9878
Signed-off-by: Jan Vcelak <jvcelak@redhat.com>
ce9878
---
ce9878
 contrib/eqn2graph/eqn2graph.sh    |  2 ++
ce9878
 contrib/gdiffmk/tests/runtests.in |  5 +++--
ce9878
 contrib/grap2graph/grap2graph.sh  |  2 ++
ce9878
 contrib/groffer/main_subs.pl      | 10 +++++-----
ce9878
 contrib/groffer/roff2.pl          |  2 +-
ce9878
 contrib/pdfmark/pdfroff.man       |  5 +++--
ce9878
 contrib/pic2graph/pic2graph.sh    |  2 ++
ce9878
 doc/fixinfo.sh                    |  5 +++--
ce9878
 doc/groff.info-2                  |  6 +++---
ce9878
 doc/groff.texinfo                 |  6 +++---
ce9878
 gendef.sh                         | 10 +++-------
ce9878
 11 files changed, 30 insertions(+), 25 deletions(-)
ce9878
ce9878
diff --git a/contrib/eqn2graph/eqn2graph.sh b/contrib/eqn2graph/eqn2graph.sh
ce9878
index ee7cc5f..13edf78 100644
ce9878
--- a/contrib/eqn2graph/eqn2graph.sh
ce9878
+++ b/contrib/eqn2graph/eqn2graph.sh
ce9878
@@ -67,6 +67,8 @@ for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
ce9878
 
ce9878
     tmp=$d/eqn2graph$$-$RANDOM
ce9878
     (umask 077 && mkdir $tmp) 2> /dev/null && break
ce9878
+
ce9878
+    tmp=
ce9878
 done;
ce9878
 if test -z "$tmp"; then
ce9878
     echo "$0: cannot create temporary directory" >&2
ce9878
diff --git a/contrib/gdiffmk/tests/runtests.in b/contrib/gdiffmk/tests/runtests.in
ce9878
index 714ce48..40a35c4 100644
ce9878
--- a/contrib/gdiffmk/tests/runtests.in
ce9878
+++ b/contrib/gdiffmk/tests/runtests.in
ce9878
@@ -56,8 +56,9 @@ function TestResult {
ce9878
 	fi
ce9878
 }
ce9878
 
ce9878
-tmpfile=/tmp/$$
ce9878
-trap 'rm -f ${tmpfile}' 0 1 2 3 15
ce9878
+tmpfile="`mktemp -t gdiffmk-runtests.XXXXXXXXXX`" || exit
ce9878
+trap 'rm -f -- "$tmpfile"' EXIT
ce9878
+trap 'trap - EXIT; rm -f -- "$tmpfile"; exit 1' HUP INT QUIT TERM
ce9878
 
ce9878
 #	Run tests.
ce9878
 
ce9878
diff --git a/contrib/grap2graph/grap2graph.sh b/contrib/grap2graph/grap2graph.sh
ce9878
index 58544e1..aeab832 100644
ce9878
--- a/contrib/grap2graph/grap2graph.sh
ce9878
+++ b/contrib/grap2graph/grap2graph.sh
ce9878
@@ -63,6 +63,8 @@ for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
ce9878
 
ce9878
     tmp=$d/grap2graph$$-$RANDOM
ce9878
     (umask 077 && mkdir $tmp) 2> /dev/null && break
ce9878
+
ce9878
+    tmp=
ce9878
 done;
ce9878
 if test -z "$tmp"; then
ce9878
     echo "$0: cannot create temporary directory" >&2
ce9878
diff --git a/contrib/groffer/main_subs.pl b/contrib/groffer/main_subs.pl
ce9878
index 90627cc..76896cd 100644
ce9878
--- a/contrib/groffer/main_subs.pl
ce9878
+++ b/contrib/groffer/main_subs.pl
ce9878
@@ -1239,7 +1239,7 @@ sub main_temp {
ce9878
   our $fh_stdin;
ce9878
   our $tmp_cat;
ce9878
   our $tmp_stdin;
ce9878
-  my $template = 'groffer_' . "$$" . '_XXXX';
ce9878
+  my $template = 'groffer_' . "$$" . '_XXXXXXXXXX';
ce9878
   foreach ($ENV{'GROFF_TMPDIR'}, $ENV{'TMPDIR'}, $ENV{'TMP'}, $ENV{'TEMP'},
ce9878
 	   $ENV{'TEMPDIR'}, File::Spec->catfile($ENV{'HOME'}, 'tmp')) {
ce9878
     if ($_ && -d $_ && -w $_) {
ce9878
@@ -1271,12 +1271,12 @@ sub main_temp {
ce9878
 
ce9878
   # further argument: SUFFIX => '.sh'
ce9878
   if ($Debug{'KEEP'}) {
ce9878
-    ($fh_cat, $tmp_cat) = tempfile(',cat_XXXX', DIR => $tmpdir);
ce9878
-    ($fh_stdin, $tmp_stdin) = tempfile(',stdin_XXXX', DIR => $tmpdir);
ce9878
+    ($fh_cat, $tmp_cat) = tempfile(',cat_XXXXXXXXXX', DIR => $tmpdir);
ce9878
+    ($fh_stdin, $tmp_stdin) = tempfile(',stdin_XXXXXXXXXX', DIR => $tmpdir);
ce9878
   } else {
ce9878
-    ($fh_cat, $tmp_cat) = tempfile(',cat_XXXX', UNLINK => 1,
ce9878
+    ($fh_cat, $tmp_cat) = tempfile(',cat_XXXXXXXXXX', UNLINK => 1,
ce9878
 				   DIR => $tmpdir);
ce9878
-    ($fh_stdin, $tmp_stdin) = tempfile(',stdin_XXXX', UNLINK => 1,
ce9878
+    ($fh_stdin, $tmp_stdin) = tempfile(',stdin_XXXXXXXXXX', UNLINK => 1,
ce9878
 				       DIR => $tmpdir);
ce9878
   }
ce9878
 }				# main_temp()
ce9878
diff --git a/contrib/groffer/roff2.pl b/contrib/groffer/roff2.pl
ce9878
index d8dad3f..f0ca9f2 100755
ce9878
--- a/contrib/groffer/roff2.pl
ce9878
+++ b/contrib/groffer/roff2.pl
ce9878
@@ -123,7 +123,7 @@ if ($Has_Groffer) {
ce9878
 	last;
ce9878
       }
ce9878
     }
ce9878
-    my $template = $Name . '_XXXX';
ce9878
+    my $template = $Name . '_XXXXXXXXXX';
ce9878
     my ($fh, $stdin);
ce9878
     if ($tempdir) {
ce9878
       ($fh, $stdin) = tempfile($template, UNLINK => 1, DIR => $tempdir) ||
ce9878
diff --git a/contrib/pdfmark/pdfroff.man b/contrib/pdfmark/pdfroff.man
ce9878
index ec412bb..faf2898 100644
ce9878
--- a/contrib/pdfmark/pdfroff.man
ce9878
+++ b/contrib/pdfmark/pdfroff.man
ce9878
@@ -555,7 +555,7 @@ defaults to
ce9878
 .B GROFF_TMPDIR
ce9878
 Identifies the directory in which
ce9878
 .B pdfroff
ce9878
-should create temporary files.
ce9878
+should create a subdirectory for its temporary files.
ce9878
 .
ce9878
 If
ce9878
 .B \%GROFF_TMPDIR
ce9878
@@ -568,7 +568,8 @@ and
ce9878
 .B TEMP
ce9878
 are considered in turn, as possible temporary file repositories.
ce9878
 If none of these are set, then temporary files are created
ce9878
-in the current directory.
ce9878
+in a subdirectory of
ce9878
+.BR /tmp .
ce9878
 .
ce9878
 .TP
ce9878
 .B GROFF_GHOSTSCRIPT_INTERPRETER
ce9878
diff --git a/contrib/pic2graph/pic2graph.sh b/contrib/pic2graph/pic2graph.sh
ce9878
index 72c5477..6b3360d 100644
ce9878
--- a/contrib/pic2graph/pic2graph.sh
ce9878
+++ b/contrib/pic2graph/pic2graph.sh
ce9878
@@ -78,6 +78,8 @@ for d in "$GROFF_TMPDIR" "$TMPDIR" "$TMP" "$TEMP" /tmp; do
ce9878
     tmp=$d/pic2graph$$-$RANDOM
ce9878
     (umask 077 && mkdir $tmp) 2> /dev/null \
ce9878
     && break
ce9878
+
ce9878
+    tmp=
ce9878
 done;
ce9878
 if test -z "$tmp"; then
ce9878
     echo "$0: cannot create temporary directory" >&2
ce9878
diff --git a/doc/fixinfo.sh b/doc/fixinfo.sh
ce9878
index 2c853f8..6954e6a 100644
ce9878
--- a/doc/fixinfo.sh
ce9878
+++ b/doc/fixinfo.sh
ce9878
@@ -22,8 +22,9 @@
ce9878
 # groff.texinfo macro code.  Hopefully, a new texinfo version makes it
ce9878
 # unnecessary.
ce9878
 
ce9878
-t=${TMPDIR-.}/gro$$.tmp
ce9878
-
ce9878
+t="`mktemp -t groff-fixinfo.XXXXXXXXXX`" || exit
ce9878
+trap 'rm -f -- "$t"' EXIT
ce9878
+trap 'trap - EXIT; rm -f -- "$t"; exit 1' HUP INT QUIT TERM
ce9878
 cat $1 | sed '
ce9878
 1 {
ce9878
   N
ce9878
diff --git a/doc/groff.info-2 b/doc/groff.info-2
ce9878
index 7eaae86..e7dab72 100644
ce9878
--- a/doc/groff.info-2
ce9878
+++ b/doc/groff.info-2
ce9878
@@ -1697,9 +1697,9 @@ not there, 'groff' would not know when to stop.
ce9878
      time into a document:
ce9878
 
ce9878
           .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
ce9878
-                       (localtime(time))[2,1,0]' > /tmp/x\n[$$]
ce9878
-          .so /tmp/x\n[$$]
ce9878
-          .sy rm /tmp/x\n[$$]
ce9878
+                       (localtime(time))[2,1,0]' > timefile\n[$$]
ce9878
+          .so timefile\n[$$]
ce9878
+          .sy rm timefile\n[$$]
ce9878
           \nH:\nM:\nS
ce9878
 
ce9878
      Note that this works by having the 'perl' script (run by 'sy')
ce9878
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
ce9878
index 066b527..83684da 100644
ce9878
--- a/doc/groff.texinfo
ce9878
+++ b/doc/groff.texinfo
ce9878
@@ -13736,9 +13736,9 @@ into a document:
ce9878
 @pindex perl
ce9878
 @Example
ce9878
 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
ce9878
-             (localtime(time))[2,1,0]' > /tmp/x\n[$$]
ce9878
-.so /tmp/x\n[$$]
ce9878
-.sy rm /tmp/x\n[$$]
ce9878
+             (localtime(time))[2,1,0]' > timefile\n[$$]
ce9878
++.so timefile\n[$$]
ce9878
++.sy rm timefile\n[$$]
ce9878
 \nH:\nM:\nS
ce9878
 @endExample
ce9878
 
ce9878
diff --git a/gendef.sh b/gendef.sh
ce9878
index 41a511b..050bcbe 100644
ce9878
--- a/gendef.sh
ce9878
+++ b/gendef.sh
ce9878
@@ -33,11 +33,9 @@ do
ce9878
 #define $def"
ce9878
 done
ce9878
 
ce9878
-# Use $TMPDIR if defined.  Default to cwd, for non-Unix systems
ce9878
-# which don't have /tmp on each drive (we are going to remove
ce9878
-# the file before we exit anyway).  Put the PID in the basename,
ce9878
-# since the extension can only hold 3 characters on MS-DOS.
ce9878
-t=${TMPDIR-.}/gro$$.tmp
ce9878
+t="`mktemp -t groff-gendef.XXXXXXXXXX`" || exit
ce9878
+trap 'rm -f -- "$t"' EXIT
ce9878
+trap 'trap - EXIT; rm -f -- "$t"; exit 1' HUP INT QUIT TERM
ce9878
 
ce9878
 sed -e 's/=/ /' >$t <
ce9878
 $defs
ce9878
@@ -45,8 +43,6 @@ EOF
ce9878
 
ce9878
 test -r $file && cmp -s $t $file || cp $t $file
ce9878
 
ce9878
-rm -f $t
ce9878
-
ce9878
 exit 0
ce9878
 
ce9878
 # eof
ce9878
-- 
ce9878
1.9.3
ce9878