Lines 1-94
Link Here
|
1 |
Patch for CVE-2008-3863 and CVE-2008-4306 |
|
|
2 |
|
3 |
Obtained from: http://cvs.fedoraproject.org/viewvc/devel/enscript/enscript-CVE-2008-3863%2BCVE-2008-4306.patch?revision=1.1 |
4 |
|
5 |
--- src/psgen.c |
6 |
+++ src/psgen.c 2008-10-29 10:43:08.512598143 +0100 |
7 |
@@ -24,6 +24,7 @@ |
8 |
* Boston, MA 02111-1307, USA. |
9 |
*/ |
10 |
|
11 |
+#include <limits.h> |
12 |
#include "gsint.h" |
13 |
|
14 |
/* |
15 |
@@ -124,7 +125,7 @@ struct gs_token_st |
16 |
double xscale; |
17 |
double yscale; |
18 |
int llx, lly, urx, ury; /* Bounding box. */ |
19 |
- char filename[512]; |
20 |
+ char filename[PATH_MAX]; |
21 |
char *skipbuf; |
22 |
unsigned int skipbuf_len; |
23 |
unsigned int skipbuf_pos; |
24 |
@@ -135,11 +136,11 @@ struct gs_token_st |
25 |
Color bgcolor; |
26 |
struct |
27 |
{ |
28 |
- char name[512]; |
29 |
+ char name[PATH_MAX]; |
30 |
FontPoint size; |
31 |
InputEncoding encoding; |
32 |
} font; |
33 |
- char filename[512]; |
34 |
+ char filename[PATH_MAX]; |
35 |
} u; |
36 |
}; |
37 |
|
38 |
@@ -248,7 +249,7 @@ static int do_print = 1; |
39 |
static int user_fontp = 0; |
40 |
|
41 |
/* The user ^@font{}-defined font. */ |
42 |
-static char user_font_name[256]; |
43 |
+static char user_font_name[PATH_MAX]; |
44 |
static FontPoint user_font_pt; |
45 |
static InputEncoding user_font_encoding; |
46 |
|
47 |
@@ -978,7 +979,8 @@ large for page\n"), |
48 |
FATAL ((stderr, |
49 |
_("user font encoding can be only the system's default or `ps'"))); |
50 |
|
51 |
- strcpy (user_font_name, token.u.font.name); |
52 |
+ memset (user_font_name, 0, sizeof(user_font_name)); |
53 |
+ strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1); |
54 |
user_font_pt.w = token.u.font.size.w; |
55 |
user_font_pt.h = token.u.font.size.h; |
56 |
user_font_encoding = token.u.font.encoding; |
57 |
@@ -1444,7 +1446,7 @@ read_special_escape (InputStream *is, To |
58 |
buf[i] = ch; |
59 |
if (i + 1 >= sizeof (buf)) |
60 |
FATAL ((stderr, _("too long argument for %s escape:\n%.*s"), |
61 |
- escapes[i].name, i, buf)); |
62 |
+ escapes[e].name, i, buf)); |
63 |
} |
64 |
buf[i] = '\0'; |
65 |
|
66 |
@@ -1452,7 +1454,8 @@ read_special_escape (InputStream *is, To |
67 |
switch (escapes[e].escape) |
68 |
{ |
69 |
case ESC_FONT: |
70 |
- strcpy (token->u.font.name, buf); |
71 |
+ memset (token->u.font.name, 0, sizeof(token->u.font.name)); |
72 |
+ strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1); |
73 |
|
74 |
/* Check for the default font. */ |
75 |
if (strcmp (token->u.font.name, "default") == 0) |
76 |
@@ -1465,7 +1468,8 @@ read_special_escape (InputStream *is, To |
77 |
FATAL ((stderr, _("malformed font spec for ^@font escape: %s"), |
78 |
token->u.font.name)); |
79 |
|
80 |
- strcpy (token->u.font.name, cp); |
81 |
+ memset (token->u.font.name, 0, sizeof(token->u.font.name)); |
82 |
+ strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1); |
83 |
xfree (cp); |
84 |
} |
85 |
token->type = tFONT; |
86 |
@@ -1544,7 +1548,8 @@ read_special_escape (InputStream *is, To |
87 |
break; |
88 |
|
89 |
case ESC_SETFILENAME: |
90 |
- strcpy (token->u.filename, buf); |
91 |
+ memset (token->u.filename, 0, sizeof(token->u.font.name)); |
92 |
+ strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1); |
93 |
token->type = tSETFILENAME; |
94 |
break; |