diff --git a/ChangeLog b/ChangeLog index 40fa27a8d..87e648f0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-02-18 Werner Lemberg + + [type1] Fix signedness issues. + + * include/internal/psaux.h, include/internal/t1types.h, + src/psaux/psobjs.c, src/psaux/psobjs.h, src/psaux/t1decode.c, + src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1parse.c: Apply. + 2015-02-18 Werner Lemberg [psaux, type1] Fix minor AFM issues. diff --git a/include/internal/psaux.h b/include/internal/psaux.h index cb77b5662..585ce38cc 100644 --- a/include/internal/psaux.h +++ b/include/internal/psaux.h @@ -365,7 +365,7 @@ FT_BEGIN_HEADER (*to_bytes)( PS_Parser parser, FT_Byte* bytes, FT_Offset max_bytes, - FT_Long* pnum_bytes, + FT_ULong* pnum_bytes, FT_Bool delimiters ); FT_Int @@ -675,7 +675,7 @@ FT_BEGIN_HEADER FT_Byte** glyph_names; FT_Int lenIV; /* internal for sub routine calls */ - FT_UInt num_subrs; + FT_Int num_subrs; FT_Byte** subrs; FT_UInt* subrs_len; /* array of subrs length (optional) */ diff --git a/include/internal/t1types.h b/include/internal/t1types.h index 5e5fd77ef..029acc400 100644 --- a/include/internal/t1types.h +++ b/include/internal/t1types.h @@ -127,7 +127,7 @@ FT_BEGIN_HEADER typedef struct CID_SubrsRec_ { - FT_UInt num_subrs; + FT_Int num_subrs; FT_Byte** code; } CID_SubrsRec, *CID_Subrs; diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index 750e37d58..c62e23f5b 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -1373,7 +1373,7 @@ ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, FT_Offset max_bytes, - FT_Long* pnum_bytes, + FT_ULong* pnum_bytes, FT_Bool delimiters ) { FT_Error error = FT_Err_Ok; diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h index 8bfb9ea6c..bf879c1fa 100644 --- a/src/psaux/psobjs.h +++ b/src/psaux/psobjs.h @@ -112,7 +112,7 @@ FT_BEGIN_HEADER ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, FT_Offset max_bytes, - FT_Long* pnum_bytes, + FT_ULong* pnum_bytes, FT_Bool delimiters ); diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index a8274f1b9..1192add0d 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -1346,7 +1346,7 @@ FT_TRACE4(( " callsubr" )); idx = Fix2Int( top[0] ); - if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs ) + if ( idx < 0 || idx >= decoder->num_subrs ) { FT_ERROR(( "t1_decoder_parse_charstrings:" " invalid subrs index\n" )); diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 546f3e162..1547ad1d9 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -92,7 +92,7 @@ if ( !error ) error = decoder->funcs.parse_charstrings( decoder, (FT_Byte*)char_string->pointer, - char_string->length ); + (FT_UInt)char_string->length ); #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -194,7 +194,7 @@ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) { /* now get load the unscaled outline */ - (void)T1_Parse_Glyph( &decoder, glyph_index ); + (void)T1_Parse_Glyph( &decoder, (FT_UInt)glyph_index ); if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance ) *max_advance = decoder.builder.advance.x; diff --git a/src/type1/t1load.c b/src/type1/t1load.c index bd3eca651..25b66a497 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -450,11 +450,11 @@ if ( design < p_design ) { - after = p; + after = (FT_Int)p; break; } - before = p; + before = (FT_Int)p; } /* now interpolate if necessary */ @@ -692,7 +692,9 @@ } num_axis = n_axis; - error = t1_allocate_blend( face, num_designs, num_axis ); + error = t1_allocate_blend( face, + (FT_UInt)num_designs, + (FT_UInt)num_axis ); if ( error ) goto Exit; blend = face->blend; @@ -757,7 +759,7 @@ old_cursor = parser->root.cursor; old_limit = parser->root.limit; - error = t1_allocate_blend( face, 0, num_axis ); + error = t1_allocate_blend( face, 0, (FT_UInt)num_axis ); if ( error ) goto Exit; blend = face->blend; @@ -848,7 +850,7 @@ if ( !blend || !blend->num_designs ) { - error = t1_allocate_blend( face, num_designs, 0 ); + error = t1_allocate_blend( face, (FT_UInt)num_designs, 0 ); if ( error ) goto Exit; blend = face->blend; @@ -890,8 +892,8 @@ parse_buildchar( T1_Face face, T1_Loader loader ) { - face->len_buildchar = T1_ToFixedArray( &loader->parser, 0, NULL, 0 ); - + face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser, + 0, NULL, 0 ); return; } @@ -1038,9 +1040,11 @@ } + /* return 1 in case of success */ + static int read_binary_data( T1_Parser parser, - FT_Long* size, + FT_ULong* size, FT_Byte** base, FT_Bool incremental ) { @@ -1072,7 +1076,7 @@ if ( s >= 0 && s < limit - *base ) { parser->root.cursor += s + 1; - *size = s; + *size = (FT_ULong)s; return !parser->root.error; } } @@ -1407,7 +1411,8 @@ /* */ for (;;) { - FT_Long idx, size; + FT_Long idx; + FT_ULong size; FT_Byte* base; @@ -1457,7 +1462,7 @@ /* some fonts define empty subr records -- this is not totally */ /* compliant to the specification (which says they should at */ /* least contain a `return'), but we support them anyway */ - if ( size < face->type1.private_dict.lenIV ) + if ( size < (FT_ULong)face->type1.private_dict.lenIV ) { error = FT_THROW( Invalid_File_Format ); goto Fail; @@ -1468,7 +1473,7 @@ goto Fail; FT_MEM_COPY( temp, base, size ); psaux->t1_decrypt( temp, size, 4330 ); - size -= face->type1.private_dict.lenIV; + size -= (FT_ULong)face->type1.private_dict.lenIV; error = T1_Add_Table( table, (FT_Int)idx, temp + face->type1.private_dict.lenIV, size ); FT_FREE( temp ); @@ -1508,7 +1513,7 @@ FT_Byte* cur; FT_Byte* limit = parser->root.limit; FT_Int n, num_glyphs; - FT_UInt notdef_index = 0; + FT_Int notdef_index = 0; FT_Byte notdef_found = 0; @@ -1555,7 +1560,7 @@ for (;;) { - FT_Long size; + FT_ULong size; FT_Byte* base; @@ -1649,7 +1654,7 @@ FT_Byte* temp; - if ( size <= face->type1.private_dict.lenIV ) + if ( size <= (FT_ULong)face->type1.private_dict.lenIV ) { error = FT_THROW( Invalid_File_Format ); goto Fail; @@ -1660,7 +1665,7 @@ goto Fail; FT_MEM_COPY( temp, base, size ); psaux->t1_decrypt( temp, size, 4330 ); - size -= face->type1.private_dict.lenIV; + size -= (FT_ULong)face->type1.private_dict.lenIV; error = T1_Add_Table( code_table, n, temp + face->type1.private_dict.lenIV, size ); FT_FREE( temp ); @@ -1846,7 +1851,7 @@ parse_dict( T1_Face face, T1_Loader loader, FT_Byte* base, - FT_Long size ) + FT_ULong size ) { T1_Parser parser = &loader->parser; FT_Byte *limit, *start_binary = NULL; @@ -1902,7 +1907,7 @@ else if ( *cur == 'R' && cur + 6 < limit && *(cur + 1) == 'D' && have_integer ) { - FT_Long s; + FT_ULong s; FT_Byte* b; @@ -1915,7 +1920,7 @@ else if ( *cur == '-' && cur + 6 < limit && *(cur + 1) == '|' && have_integer ) { - FT_Long s; + FT_ULong s; FT_Byte* b; diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c index 40ffd07c1..feea224f6 100644 --- a/src/type1/t1parse.c +++ b/src/type1/t1parse.c @@ -273,7 +273,7 @@ /* made of several segments. We thus first read the number of */ /* segments to compute the total size of the private dictionary */ /* then re-read them into memory. */ - FT_Long start_pos = FT_STREAM_POS(); + FT_ULong start_pos = FT_STREAM_POS(); FT_UShort tag; @@ -411,9 +411,11 @@ /* fine that are violating this limitation, so we add a heuristic */ /* test to stop at \r only if it is not used for EOL. */ - pos_lf = ft_memchr( cur, '\n', limit - cur ); - test_cr = FT_BOOL( !pos_lf || - pos_lf > ft_memchr( cur, '\r', limit - cur ) ); + pos_lf = ft_memchr( cur, '\n', (size_t)( limit - cur ) ); + test_cr = FT_BOOL( !pos_lf || + pos_lf > ft_memchr( cur, + '\r', + (size_t)( limit - cur ) ) ); while ( cur < limit && ( *cur == ' ' || @@ -429,7 +431,7 @@ goto Exit; } - size = (FT_ULong)( parser->base_len - ( cur - parser->base_dict ) ); + size = parser->base_len - (FT_ULong)( cur - parser->base_dict ); if ( parser->in_memory ) { @@ -459,7 +461,7 @@ ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) ) { /* ASCII hexadecimal encoding */ - FT_Long len; + FT_ULong len; parser->root.cursor = cur;