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

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