* src/type1/t1load.c (read_binary_data): Return more meaningful value. (parse_encoding, parse_subrs, parse_charstrings, parse_dict): Check parser error value after call to T1_Skip_PS_Token (where necessary). * src/type1/t1parse.c (T1_Get_Private_Dict): Check parser error value after call to T1_Skip_PS_Token. * src/cid/cidparse.c (cid_parser_new): Check parser error value after call to cid_parser_skip_PS_token. * src/type42/t42parse.c (t42_parse_encoding, t42_parse_sfnts, t42_parse_charstrings, t42_parse_dict): Check parser error value after call to T1_Skip_PS_Token (where necessary). * src/psaux/psobjc.c (skip_string, ps_parser_skip_PS_token, ps_tobytes): Add error messages.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
diff --git a/ChangeLog b/ChangeLog
index b034bb0..56bf06d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2005-02-13 Werner Lemberg <wl@gnu.org>
+
+ * src/type1/t1load.c (read_binary_data): Return more meaningful
+ value.
+ (parse_encoding, parse_subrs, parse_charstrings, parse_dict): Check
+ parser error value after call to T1_Skip_PS_Token (where necessary).
+
+ * src/type1/t1parse.c (T1_Get_Private_Dict): Check parser error
+ value after call to T1_Skip_PS_Token.
+
+ * src/cid/cidparse.c (cid_parser_new): Check parser error value
+ after call to cid_parser_skip_PS_token.
+
+ * src/type42/t42parse.c (t42_parse_encoding, t42_parse_sfnts,
+ t42_parse_charstrings, t42_parse_dict): Check parser error value
+ after call to T1_Skip_PS_Token (where necessary).
+
+ * src/psaux/psobjc.c (skip_string, ps_parser_skip_PS_token,
+ ps_tobytes): Add error messages.
+
2005-02-12 Werner Lemberg <wl@gnu.org>
* configure: Output more variables to the created Makefile so that
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index 3f18749..a964d81 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 parser (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -152,6 +152,9 @@
while ( cur < limit )
{
+ if ( parser->root.error )
+ break;
+
if ( *cur == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 )
{
if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 )
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index d02986c..2480c3f 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -429,7 +429,10 @@
}
if ( cur < limit && *cur != '>' )
+ {
+ FT_ERROR(( "skip_string: missing closing delimiter `>'\n" ));
parser->error = PSaux_Err_Invalid_File_Format;
+ }
else
cur++;
@@ -492,6 +495,8 @@
cur++;
if ( cur >= limit || *cur != '>' ) /* >> */
{
+ FT_ERROR(( "ps_parser_skip_PS_token: "
+ "unexpected closing delimiter `>'\n" ));
parser->error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
@@ -516,6 +521,8 @@
if ( *cur == ')' )
{
+ FT_ERROR(( "ps_parser_skip_PS_token: "
+ "unexpected closing delimiter `)'\n" ));
parser->error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
@@ -795,6 +802,7 @@
{
if ( *cur != '<' )
{
+ FT_ERROR(( "ps_tobytes: Missing starting delimiter `<'\n" ));
error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
@@ -834,6 +842,7 @@
{
if ( cur < limit && *cur != '>' )
{
+ FT_ERROR(( "ps_tobytes: Missing closing delimiter `>'\n" ));
error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 9355288..a9015c5 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 font loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -1008,7 +1008,7 @@
*base = parser->root.cursor + 1;
parser->root.cursor += *size + 1;
- return 1;
+ return !parser->root.error;
}
FT_ERROR(( "read_binary_data: invalid size field\n" ));
@@ -1202,6 +1202,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
len = parser->root.cursor - cur;
@@ -1277,7 +1279,9 @@
/* position the parser right before the `dup' of the first subr */
T1_Skip_PS_Token( parser ); /* `array' */
- T1_Skip_Spaces ( parser );
+ if ( parser->root.error )
+ return;
+ T1_Skip_Spaces( parser );
/* initialize subrs array -- with synthetic fonts it is possible */
/* we get here twice */
@@ -1315,6 +1319,8 @@
/* `noaccess' & `put'. We position the parser right */
/* before the next `dup', if any. */
T1_Skip_PS_Token( parser ); /* `NP' or `|' or `noaccess' */
+ if ( parser->root.error )
+ return;
T1_Skip_Spaces ( parser );
if ( ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
@@ -1451,6 +1457,8 @@
}
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
if ( *cur == '/' )
{
@@ -1723,7 +1731,9 @@
break;
T1_Skip_PS_Token( parser );
- T1_Skip_Spaces ( parser );
+ if ( parser->root.error )
+ goto Exit;
+ T1_Skip_Spaces( parser );
cur = parser->root.cursor;
}
@@ -1759,6 +1769,8 @@
{
start_binary = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ goto Exit;
have_integer = 1;
}
@@ -1801,6 +1813,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ goto Exit;
len = parser->root.cursor - cur;
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index 544aa09..501d9f2 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 parser (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -337,6 +337,8 @@
goto Found;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ break;
T1_Skip_Spaces ( parser );
cur = parser->root.cursor;
}
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 30846c0..b5139e5 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -4,7 +4,7 @@
/* */
/* Type 42 font parser (body). */
/* */
-/* Copyright 2002, 2003, 2004 by Roberto Alameda. */
+/* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@@ -412,14 +412,16 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
- char_table->elements[charcode][len] = '\0';
if ( parser->root.error )
return;
+ char_table->elements[charcode][len] = '\0';
n++;
}
@@ -550,6 +552,8 @@
string_size = T1_ToInt( parser );
T1_Skip_PS_Token( parser ); /* `RD' */
+ if ( parser->root.error )
+ return;
string_buf = parser->root.cursor + 1; /* one space after `RD' */
@@ -691,6 +695,8 @@
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
@@ -705,6 +711,8 @@
break;
}
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
T1_Skip_Spaces( parser );
}
}
@@ -767,6 +775,8 @@
break;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ return;
if ( *cur == '/' )
{
@@ -1003,6 +1013,8 @@
break;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ goto Exit;
T1_Skip_Spaces ( parser );
cur = parser->root.cursor;
}
@@ -1033,6 +1045,8 @@
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ goto Exit;
len = parser->root.cursor - cur;
@@ -1069,11 +1083,16 @@
}
}
else
+ {
T1_Skip_PS_Token( parser );
+ if ( parser->root.error )
+ goto Exit;
+ }
T1_Skip_Spaces( parser );
}
+ Exit:
return parser->root.error;
}