diff --git a/ChangeLog b/ChangeLog index b034bb043..56bf06d95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2005-02-13 Werner Lemberg + + * 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 * configure: Output more variables to the created Makefile so that diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index 3f18749f6..a964d8157 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 d02986cee..2480c3fa2 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 9355288d0..a9015c5b2 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 544aa093f..501d9f2ab 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 30846c07b..b5139e533 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; }