components/enscript/patches/enscript-CVE-2008-3863+CVE-2008-4306.patch
author Jiri Sasek <Jiri.Sasek@Oracle.COM>
Mon, 07 Jul 2014 04:16:19 -0700
changeset 1986 ec77e9bb9f57
parent 1132 a62391631ea1
permissions -rw-r--r--
17027615 smbd still dumps core with patch 119758-27(SAMBA 3.6.12) in AIO mode with SAMFS
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1132
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
--- enscript-1.6.4/src/psgen.c
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
+++ enscript-1.6.4/src/psgen.c	2008-10-29 10:43:08.512598143 +0100
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
@@ -24,6 +24,7 @@
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
  * Boston, MA 02111-1307, USA.
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
  */
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
+#include <limits.h>
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
 #include "gsint.h"
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
 /*
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
@@ -124,7 +125,7 @@ struct gs_token_st
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
 	  double xscale;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
 	  double yscale;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
 	  int llx, lly, urx, ury; /* Bounding box. */
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
-	  char filename[512];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
+	  char filename[PATH_MAX];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
 	  char *skipbuf;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
 	  unsigned int skipbuf_len;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
 	  unsigned int skipbuf_pos;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
@@ -135,11 +136,11 @@ struct gs_token_st
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
       Color bgcolor;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
       struct
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
 	{
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
-	  char name[512];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+	  char name[PATH_MAX];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
 	  FontPoint size;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
 	  InputEncoding encoding;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
 	} font;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
-      char filename[512];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
+      char filename[PATH_MAX];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
     } u;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
 };
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
@@ -248,7 +249,7 @@ static int do_print = 1;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
 static int user_fontp = 0;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
 /* The user ^@font{}-defined font. */
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
-static char user_font_name[256];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
+static char user_font_name[PATH_MAX];
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
 static FontPoint user_font_pt;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
 static InputEncoding user_font_encoding;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
@@ -978,7 +979,8 @@ large for page\n"),
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
 			FATAL ((stderr,
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
 				_("user font encoding can be only the system's default or `ps'")));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
-		      strcpy (user_font_name, token.u.font.name);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
+		      memset  (user_font_name, 0, sizeof(user_font_name));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
+		      strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
 		      user_font_pt.w = token.u.font.size.w;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
 		      user_font_pt.h = token.u.font.size.h;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
 		      user_font_encoding = token.u.font.encoding;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    53
@@ -1444,7 +1446,7 @@ read_special_escape (InputStream *is, To
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
 	  buf[i] = ch;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    55
 	  if (i + 1 >= sizeof (buf))
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    56
 	    FATAL ((stderr, _("too long argument for %s escape:\n%.*s"),
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    57
-		    escapes[i].name, i, buf));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
+		    escapes[e].name, i, buf));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
 	}
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    60
       buf[i] = '\0';
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    61
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    62
@@ -1452,7 +1454,8 @@ read_special_escape (InputStream *is, To
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    63
       switch (escapes[e].escape)
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    64
 	{
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
 	case ESC_FONT:
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    66
-	  strcpy (token->u.font.name, buf);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    67
+	  memset  (token->u.font.name, 0, sizeof(token->u.font.name));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    68
+	  strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    69
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    70
 	  /* Check for the default font. */
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    71
 	  if (strcmp (token->u.font.name, "default") == 0)
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    72
@@ -1465,7 +1468,8 @@ read_special_escape (InputStream *is, To
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    73
 		FATAL ((stderr, _("malformed font spec for ^@font escape: %s"),
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    74
 			token->u.font.name));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    75
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    76
-	      strcpy (token->u.font.name, cp);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    77
+	      memset  (token->u.font.name, 0, sizeof(token->u.font.name));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    78
+	      strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    79
 	      xfree (cp);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    80
 	    }
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    81
 	  token->type = tFONT;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    82
@@ -1544,7 +1548,8 @@ read_special_escape (InputStream *is, To
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    83
 	  break;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    84
 
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    85
 	case ESC_SETFILENAME:
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    86
-	  strcpy (token->u.filename, buf);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    87
+	  memset  (token->u.filename, 0, sizeof(token->u.font.name));
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    88
+	  strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1);
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    89
 	  token->type = tSETFILENAME;
a62391631ea1 16170971 Move enscript from the Desktop consolidation to Userland
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    90
 	  break;