OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* cidparse.c */ | 3 /* cidparse.c */ |
4 /* */ | 4 /* */ |
5 /* CID-keyed Type1 parser (body). */ | 5 /* CID-keyed Type1 parser (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2007, 2009, 2013, 2014 by */ | 7 /* Copyright 1996-2015 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 FT_FRAME_EXIT(); | 80 FT_FRAME_EXIT(); |
81 if ( error ) | 81 if ( error ) |
82 goto Exit; | 82 goto Exit; |
83 | 83 |
84 Again: | 84 Again: |
85 /* now, read the rest of the file until we find */ | 85 /* now, read the rest of the file until we find */ |
86 /* `StartData' or `/sfnts' */ | 86 /* `StartData' or `/sfnts' */ |
87 { | 87 { |
88 FT_Byte buffer[256 + 10]; | 88 FT_Byte buffer[256 + 10]; |
89 FT_Long read_len = 256 + 10; /* same as signed FT_Stream->size */ | 89 FT_ULong read_len = 256 + 10; |
90 FT_Byte* p = buffer; | 90 FT_Byte* p = buffer; |
91 | 91 |
92 | 92 |
93 for ( offset = FT_STREAM_POS(); ; offset += 256 ) | 93 for ( offset = FT_STREAM_POS(); ; offset += 256 ) |
94 { | 94 { |
95 FT_Long stream_len; /* same as signed FT_Stream->size */ | 95 FT_ULong stream_len; |
96 | 96 |
97 | 97 |
98 stream_len = stream->size - FT_STREAM_POS(); | 98 stream_len = stream->size - FT_STREAM_POS(); |
99 if ( stream_len == 0 ) | 99 if ( stream_len == 0 ) |
100 { | 100 { |
101 FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" )); | 101 FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" )); |
102 error = FT_THROW( Invalid_File_Format ); | 102 error = FT_THROW( Invalid_File_Format ); |
103 goto Exit; | 103 goto Exit; |
104 } | 104 } |
105 | 105 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 { | 169 { |
170 if ( parser->root.error ) | 170 if ( parser->root.error ) |
171 { | 171 { |
172 error = parser->root.error; | 172 error = parser->root.error; |
173 goto Exit; | 173 goto Exit; |
174 } | 174 } |
175 | 175 |
176 if ( cur[0] == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 ) | 176 if ( cur[0] == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 ) |
177 { | 177 { |
178 if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) | 178 if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) |
179 parser->binary_length = ft_atol( (const char *)arg2 ); | 179 { |
| 180 FT_Long tmp = ft_atol( (const char *)arg2 ); |
| 181 |
| 182 |
| 183 if ( tmp < 0 ) |
| 184 { |
| 185 FT_ERROR(( "cid_parser_new: invalid length of hex data\n" )); |
| 186 error = FT_THROW( Invalid_File_Format ); |
| 187 } |
| 188 else |
| 189 parser->binary_length = (FT_ULong)tmp; |
| 190 } |
180 | 191 |
181 goto Exit; | 192 goto Exit; |
182 } | 193 } |
183 else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 ) | 194 else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 ) |
184 { | 195 { |
185 FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" )); | 196 FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" )); |
186 error = FT_THROW( Unknown_File_Format ); | 197 error = FT_THROW( Unknown_File_Format ); |
187 goto Exit; | 198 goto Exit; |
188 } | 199 } |
189 | 200 |
(...skipping 24 matching lines...) Expand all Loading... |
214 FT_Stream stream = parser->stream; | 225 FT_Stream stream = parser->stream; |
215 | 226 |
216 | 227 |
217 FT_FRAME_RELEASE( parser->postscript ); | 228 FT_FRAME_RELEASE( parser->postscript ); |
218 } | 229 } |
219 parser->root.funcs.done( &parser->root ); | 230 parser->root.funcs.done( &parser->root ); |
220 } | 231 } |
221 | 232 |
222 | 233 |
223 /* END */ | 234 /* END */ |
OLD | NEW |