idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
5,600
|
ft_black_render( black_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
black_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return FT_THROW( Not_Ini );
if ( !outline )
return FT_THROW( Invalid );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline->contours || !outline->points )
return FT_THROW( Invalid );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
return FT_THROW( Unsupported );
if ( !target_map )
return FT_THROW( Invalid );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
return FT_THROW( Invalid );
ras.outline = *outline;
ras.target = *target_map;
worker->buff = (PLong) raster->buffer;
worker->sizeBuff = worker->buff +
raster->buffer_size / sizeof ( Long );
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
worker->grays = raster->grays;
worker->gray_width = raster->gray_width;
FT_MEM_ZERO( worker->gray_lines, worker->gray_width * 2 );
#endif
return ( params->flags & FT_RASTER_FLAG_AA )
? Render_Gray_Glyph( RAS_VAR )
: Render_Glyph( RAS_VAR );
}
|
DoS Overflow
| 0
|
ft_black_render( black_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
black_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return FT_THROW( Not_Ini );
if ( !outline )
return FT_THROW( Invalid );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline->contours || !outline->points )
return FT_THROW( Invalid );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
return FT_THROW( Unsupported );
if ( !target_map )
return FT_THROW( Invalid );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
return FT_THROW( Invalid );
ras.outline = *outline;
ras.target = *target_map;
worker->buff = (PLong) raster->buffer;
worker->sizeBuff = worker->buff +
raster->buffer_size / sizeof ( Long );
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
worker->grays = raster->grays;
worker->gray_width = raster->gray_width;
FT_MEM_ZERO( worker->gray_lines, worker->gray_width * 2 );
#endif
return ( params->flags & FT_RASTER_FLAG_AA )
? Render_Gray_Glyph( RAS_VAR )
: Render_Glyph( RAS_VAR );
}
|
@@ -2553,7 +2553,7 @@
e1 = TRUNC( e1 );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
PByte p;
@@ -2647,7 +2647,7 @@
/* bounding box instead */
if ( pxl < 0 )
pxl = e1;
- else if ( TRUNC( pxl ) >= ras.target.rows )
+ else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
pxl = e2;
/* check that the other pixel isn't set */
@@ -2662,9 +2662,9 @@
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
- if ( e1 >= 0 &&
- e1 < ras.target.rows &&
- *bits & f1 )
+ if ( e1 >= 0 &&
+ (ULong)e1 < ras.target.rows &&
+ *bits & f1 )
return;
}
else
@@ -2676,7 +2676,7 @@
e1 = TRUNC( pxl );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
|
CWE-119
| null | null |
5,601
|
ft_black_reset( black_PRaster raster,
char* pool_base,
long pool_size )
{
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
black_PWorker worker = (black_PWorker)pool_base;
raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = (long)( pool_base + pool_size -
(char*)raster->buffer );
raster->worker = worker;
}
else
{
raster->buffer = NULL;
raster->buffer_size = 0;
raster->worker = NULL;
}
}
}
|
DoS Overflow
| 0
|
ft_black_reset( black_PRaster raster,
char* pool_base,
long pool_size )
{
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
black_PWorker worker = (black_PWorker)pool_base;
raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = (long)( pool_base + pool_size -
(char*)raster->buffer );
raster->worker = worker;
}
else
{
raster->buffer = NULL;
raster->buffer_size = 0;
raster->worker = NULL;
}
}
}
|
@@ -2553,7 +2553,7 @@
e1 = TRUNC( e1 );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
PByte p;
@@ -2647,7 +2647,7 @@
/* bounding box instead */
if ( pxl < 0 )
pxl = e1;
- else if ( TRUNC( pxl ) >= ras.target.rows )
+ else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
pxl = e2;
/* check that the other pixel isn't set */
@@ -2662,9 +2662,9 @@
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
- if ( e1 >= 0 &&
- e1 < ras.target.rows &&
- *bits & f1 )
+ if ( e1 >= 0 &&
+ (ULong)e1 < ras.target.rows &&
+ *bits & f1 )
return;
}
else
@@ -2676,7 +2676,7 @@
e1 = TRUNC( pxl );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
|
CWE-119
| null | null |
5,602
|
ft_black_set_mode( black_PRaster raster,
unsigned long mode,
const char* palette )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
{
/* set 5-levels gray palette */
raster->grays[0] = palette[0];
raster->grays[1] = palette[1];
raster->grays[2] = palette[2];
raster->grays[3] = palette[3];
raster->grays[4] = palette[4];
}
#else
FT_UNUSED( raster );
FT_UNUSED( mode );
FT_UNUSED( palette );
#endif
}
|
DoS Overflow
| 0
|
ft_black_set_mode( black_PRaster raster,
unsigned long mode,
const char* palette )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
{
/* set 5-levels gray palette */
raster->grays[0] = palette[0];
raster->grays[1] = palette[1];
raster->grays[2] = palette[2];
raster->grays[3] = palette[3];
raster->grays[4] = palette[4];
}
#else
FT_UNUSED( raster );
FT_UNUSED( mode );
FT_UNUSED( palette );
#endif
}
|
@@ -2553,7 +2553,7 @@
e1 = TRUNC( e1 );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
PByte p;
@@ -2647,7 +2647,7 @@
/* bounding box instead */
if ( pxl < 0 )
pxl = e1;
- else if ( TRUNC( pxl ) >= ras.target.rows )
+ else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
pxl = e2;
/* check that the other pixel isn't set */
@@ -2662,9 +2662,9 @@
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
- if ( e1 >= 0 &&
- e1 < ras.target.rows &&
- *bits & f1 )
+ if ( e1 >= 0 &&
+ (ULong)e1 < ras.target.rows &&
+ *bits & f1 )
return;
}
else
@@ -2676,7 +2676,7 @@
e1 = TRUNC( pxl );
- if ( e1 >= 0 && e1 < ras.target.rows )
+ if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
|
CWE-119
| null | null |
5,603
|
convert_bytes_to_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = 0xFF;
}
}
|
DoS Overflow
| 0
|
convert_bytes_to_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = 0xFF;
}
}
|
@@ -205,11 +205,11 @@
goto Exit;
}
- if ( !populate_map_and_metrics &&
- ( x_offset + metrics->width > map->width ||
- y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
|
CWE-119
| null | null |
5,604
|
error_callback( png_structp png,
png_const_charp error_msg )
{
FT_Error* error = (FT_Error*)png_get_error_ptr( png );
FT_UNUSED( error_msg );
*error = FT_THROW( Out_Of_Memory );
#ifdef PNG_SETJMP_SUPPORTED
ft_longjmp( png_jmpbuf( png ), 1 );
#endif
/* if we get here, then we have no choice but to abort ... */
}
|
DoS Overflow
| 0
|
error_callback( png_structp png,
png_const_charp error_msg )
{
FT_Error* error = (FT_Error*)png_get_error_ptr( png );
FT_UNUSED( error_msg );
*error = FT_THROW( Out_Of_Memory );
#ifdef PNG_SETJMP_SUPPORTED
ft_longjmp( png_jmpbuf( png ), 1 );
#endif
/* if we get here, then we have no choice but to abort ... */
}
|
@@ -205,11 +205,11 @@
goto Exit;
}
- if ( !populate_map_and_metrics &&
- ( x_offset + metrics->width > map->width ||
- y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
|
CWE-119
| null | null |
5,605
|
multiply_alpha( int alpha,
int color )
{
int temp = ( alpha * color ) + 0x80;
return ( temp + ( temp >> 8 ) ) >> 8;
}
|
DoS Overflow
| 0
|
multiply_alpha( int alpha,
int color )
{
int temp = ( alpha * color ) + 0x80;
return ( temp + ( temp >> 8 ) ) >> 8;
}
|
@@ -205,11 +205,11 @@
goto Exit;
}
- if ( !populate_map_and_metrics &&
- ( x_offset + metrics->width > map->width ||
- y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
|
CWE-119
| null | null |
5,606
|
premultiply_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int alpha = base[3];
if ( alpha == 0 )
base[0] = base[1] = base[2] = base[3] = 0;
else
{
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
if ( alpha != 0xFF )
{
red = multiply_alpha( alpha, red );
green = multiply_alpha( alpha, green );
blue = multiply_alpha( alpha, blue );
}
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = alpha;
}
}
}
|
DoS Overflow
| 0
|
premultiply_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int alpha = base[3];
if ( alpha == 0 )
base[0] = base[1] = base[2] = base[3] = 0;
else
{
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
if ( alpha != 0xFF )
{
red = multiply_alpha( alpha, red );
green = multiply_alpha( alpha, green );
blue = multiply_alpha( alpha, blue );
}
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = alpha;
}
}
}
|
@@ -205,11 +205,11 @@
goto Exit;
}
- if ( !populate_map_and_metrics &&
- ( x_offset + metrics->width > map->width ||
- y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
|
CWE-119
| null | null |
5,607
|
warning_callback( png_structp png,
png_const_charp error_msg )
{
FT_UNUSED( png );
FT_UNUSED( error_msg );
/* Just ignore warnings. */
}
|
DoS Overflow
| 0
|
warning_callback( png_structp png,
png_const_charp error_msg )
{
FT_UNUSED( png );
FT_UNUSED( error_msg );
/* Just ignore warnings. */
}
|
@@ -205,11 +205,11 @@
goto Exit;
}
- if ( !populate_map_and_metrics &&
- ( x_offset + metrics->width > map->width ||
- y_offset + metrics->height > map->rows ||
- pix_bits != 32 ||
- map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
+ if ( !populate_map_and_metrics &&
+ ( (FT_UInt)x_offset + metrics->width > map->width ||
+ (FT_UInt)y_offset + metrics->height > map->rows ||
+ pix_bits != 32 ||
+ map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
|
CWE-119
| null | null |
5,608
|
T1_Open_Face( T1_Face face )
{
T1_LoaderRec loader;
T1_Parser parser;
T1_Font type1 = &face->type1;
PS_Private priv = &type1->private_dict;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t1_init_loader( &loader, face );
/* default values */
face->ndv_idx = -1;
face->cdv_idx = -1;
face->len_buildchar = 0;
priv->blue_shift = 7;
priv->blue_fuzz = 1;
priv->lenIV = 4;
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
parser = &loader.parser;
error = T1_New_Parser( parser,
face->root.stream,
face->root.memory,
psaux );
if ( error )
goto Exit;
error = parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
error = T1_Get_Private_Dict( parser, psaux );
if ( error )
goto Exit;
error = parse_dict( face, &loader,
parser->private_dict, parser->private_len );
if ( error )
goto Exit;
/* ensure even-ness of `num_blue_values' */
priv->num_blue_values &= ~1;
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
if ( face->blend &&
face->blend->num_default_design_vector != 0 &&
face->blend->num_default_design_vector != face->blend->num_axis )
{
/* we don't use it currently so just warn, reset, and ignore */
FT_ERROR(( "T1_Open_Face(): /DesignVector contains %u entries "
"while there are %u axes.\n",
face->blend->num_default_design_vector,
face->blend->num_axis ));
face->blend->num_default_design_vector = 0;
}
/* the following can happen for MM instances; we then treat the */
/* font as a normal PS font */
if ( face->blend &&
( !face->blend->num_designs || !face->blend->num_axis ) )
T1_Done_Blend( face );
/* another safety check */
if ( face->blend )
{
FT_UInt i;
for ( i = 0; i < face->blend->num_axis; i++ )
if ( !face->blend->design_map[i].num_points )
{
T1_Done_Blend( face );
break;
}
}
if ( face->blend )
{
if ( face->len_buildchar > 0 )
{
FT_Memory memory = face->root.memory;
if ( FT_NEW_ARRAY( face->buildchar, face->len_buildchar ) )
{
FT_ERROR(( "T1_Open_Face: cannot allocate BuildCharArray\n" ));
face->len_buildchar = 0;
goto Exit;
}
}
}
else
face->len_buildchar = 0;
#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
/* now, propagate the subrs, charstrings, and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( loader.subrs.init )
{
loader.subrs.init = 0;
type1->num_subrs = loader.num_subrs;
type1->subrs_block = loader.subrs.block;
type1->subrs = loader.subrs.elements;
type1->subrs_len = loader.subrs.lengths;
}
if ( !IS_INCREMENTAL )
if ( !loader.charstrings.init )
{
FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* the index is then stored in type1.encoding.char_index, and */
/* the name to type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t1_done_loader( &loader );
return error;
}
|
DoS Overflow
| 0
|
T1_Open_Face( T1_Face face )
{
T1_LoaderRec loader;
T1_Parser parser;
T1_Font type1 = &face->type1;
PS_Private priv = &type1->private_dict;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t1_init_loader( &loader, face );
/* default values */
face->ndv_idx = -1;
face->cdv_idx = -1;
face->len_buildchar = 0;
priv->blue_shift = 7;
priv->blue_fuzz = 1;
priv->lenIV = 4;
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
parser = &loader.parser;
error = T1_New_Parser( parser,
face->root.stream,
face->root.memory,
psaux );
if ( error )
goto Exit;
error = parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
error = T1_Get_Private_Dict( parser, psaux );
if ( error )
goto Exit;
error = parse_dict( face, &loader,
parser->private_dict, parser->private_len );
if ( error )
goto Exit;
/* ensure even-ness of `num_blue_values' */
priv->num_blue_values &= ~1;
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
if ( face->blend &&
face->blend->num_default_design_vector != 0 &&
face->blend->num_default_design_vector != face->blend->num_axis )
{
/* we don't use it currently so just warn, reset, and ignore */
FT_ERROR(( "T1_Open_Face(): /DesignVector contains %u entries "
"while there are %u axes.\n",
face->blend->num_default_design_vector,
face->blend->num_axis ));
face->blend->num_default_design_vector = 0;
}
/* the following can happen for MM instances; we then treat the */
/* font as a normal PS font */
if ( face->blend &&
( !face->blend->num_designs || !face->blend->num_axis ) )
T1_Done_Blend( face );
/* another safety check */
if ( face->blend )
{
FT_UInt i;
for ( i = 0; i < face->blend->num_axis; i++ )
if ( !face->blend->design_map[i].num_points )
{
T1_Done_Blend( face );
break;
}
}
if ( face->blend )
{
if ( face->len_buildchar > 0 )
{
FT_Memory memory = face->root.memory;
if ( FT_NEW_ARRAY( face->buildchar, face->len_buildchar ) )
{
FT_ERROR(( "T1_Open_Face: cannot allocate BuildCharArray\n" ));
face->len_buildchar = 0;
goto Exit;
}
}
}
else
face->len_buildchar = 0;
#endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */
/* now, propagate the subrs, charstrings, and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( loader.subrs.init )
{
loader.subrs.init = 0;
type1->num_subrs = loader.num_subrs;
type1->subrs_block = loader.subrs.block;
type1->subrs = loader.subrs.elements;
type1->subrs_len = loader.subrs.lengths;
}
if ( !IS_INCREMENTAL )
if ( !loader.charstrings.init )
{
FT_ERROR(( "T1_Open_Face: no `/CharStrings' array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* the index is then stored in type1.encoding.char_index, and */
/* the name to type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t1_done_loader( &loader );
return error;
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,609
|
T1_Set_MM_Blend( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
PS_Blend blend = face->blend;
FT_Error error;
FT_UInt n, m;
error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* recompute the weight vector from the blend coordinates */
for ( n = 0; n < blend->num_designs; n++ )
{
FT_Fixed result = 0x10000L; /* 1.0 fixed */
for ( m = 0; m < blend->num_axis; m++ )
{
FT_Fixed factor;
/* get current blend axis position */
factor = coords[m];
if ( factor < 0 )
factor = 0;
if ( factor > 0x10000L )
factor = 0x10000L;
if ( ( n & ( 1 << m ) ) == 0 )
factor = 0x10000L - factor;
result = FT_MulFix( result, factor );
}
blend->weight_vector[n] = result;
}
error = FT_Err_Ok;
}
return error;
}
|
DoS Overflow
| 0
|
T1_Set_MM_Blend( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
PS_Blend blend = face->blend;
FT_Error error;
FT_UInt n, m;
error = FT_ERR( Invalid_Argument );
if ( blend && blend->num_axis == num_coords )
{
/* recompute the weight vector from the blend coordinates */
for ( n = 0; n < blend->num_designs; n++ )
{
FT_Fixed result = 0x10000L; /* 1.0 fixed */
for ( m = 0; m < blend->num_axis; m++ )
{
FT_Fixed factor;
/* get current blend axis position */
factor = coords[m];
if ( factor < 0 )
factor = 0;
if ( factor > 0x10000L )
factor = 0x10000L;
if ( ( n & ( 1 << m ) ) == 0 )
factor = 0x10000L - factor;
result = FT_MulFix( result, factor );
}
blend->weight_vector[n] = result;
}
error = FT_Err_Ok;
}
return error;
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,610
|
parse_encoding( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
if ( cur >= limit )
{
FT_ERROR(( "parse_encoding: out of bounds\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* if we have a number or `[', the encoding is an array, */
/* and we must load it now */
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Bool only_immediates = 0;
/* read the number of entries in the encoding; should be 256 */
if ( *cur == '[' )
{
count = 256;
only_immediates = 1;
parser->root.cursor++;
}
else
count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit )
return;
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
if ( FT_NEW_ARRAY( encode->char_index, count ) ||
FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
parser->root.error = error;
return;
}
/* We need to `zero' out encoding_table.elements */
for ( n = 0; n < count; n++ )
{
char* notdef = (char *)".notdef";
T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
/* */
/* ... charcode /charname ... */
/* */
/* for each entry in our table. */
/* */
/* We simply look for a number followed by an immediate */
/* name. Note that this ignores correctly the sequence */
/* that is often seen in type1 fonts: */
/* */
/* 0 1 255 { 1 index exch /.notdef put } for dup */
/* */
/* used to clean the encoding array before anything else. */
/* */
/* Alternatively, if the array is directly given as */
/* */
/* /Encoding [ ... ] */
/* */
/* we only read immediates. */
n = 0;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
/* we stop when we encounter a `def' or `]' */
if ( *cur == 'd' && cur + 3 < limit )
{
if ( cur[1] == 'e' &&
cur[2] == 'f' &&
IS_PS_DELIM( cur[3] ) )
{
FT_TRACE6(( "encoding end\n" ));
cur += 3;
break;
}
}
if ( *cur == ']' )
{
FT_TRACE6(( "encoding end\n" ));
cur++;
break;
}
/* check whether we've found an entry */
if ( ft_isdigit( *cur ) || only_immediates )
{
FT_Int charcode;
if ( only_immediates )
charcode = n;
else
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
/* protect against invalid charcode */
if ( cur == parser->root.cursor )
{
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
cur = parser->root.cursor;
if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.cursor >= limit )
return;
if ( parser->root.error )
return;
len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
if ( parser->root.error )
return;
char_table->elements[charcode][len] = '\0';
n++;
}
else if ( only_immediates )
{
/* Since the current position is not updated for */
/* immediates-only mode we would get an infinite loop if */
/* we don't do anything here. */
/* */
/* This encoding array is not valid according to the type1 */
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
return;
}
T1_Skip_Spaces( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding', */
/* `ExpertEncoding', or `ISOLatin1Encoding' */
else
{
if ( cur + 17 < limit &&
ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
else if ( cur + 15 < limit &&
ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
else if ( cur + 18 < limit &&
ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
parser->root.error = FT_ERR( Ignore );
}
}
|
DoS Overflow
| 0
|
parse_encoding( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
if ( cur >= limit )
{
FT_ERROR(( "parse_encoding: out of bounds\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* if we have a number or `[', the encoding is an array, */
/* and we must load it now */
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Bool only_immediates = 0;
/* read the number of entries in the encoding; should be 256 */
if ( *cur == '[' )
{
count = 256;
only_immediates = 1;
parser->root.cursor++;
}
else
count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit )
return;
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
if ( FT_NEW_ARRAY( encode->char_index, count ) ||
FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
parser->root.error = error;
return;
}
/* We need to `zero' out encoding_table.elements */
for ( n = 0; n < count; n++ )
{
char* notdef = (char *)".notdef";
T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
/* */
/* ... charcode /charname ... */
/* */
/* for each entry in our table. */
/* */
/* We simply look for a number followed by an immediate */
/* name. Note that this ignores correctly the sequence */
/* that is often seen in type1 fonts: */
/* */
/* 0 1 255 { 1 index exch /.notdef put } for dup */
/* */
/* used to clean the encoding array before anything else. */
/* */
/* Alternatively, if the array is directly given as */
/* */
/* /Encoding [ ... ] */
/* */
/* we only read immediates. */
n = 0;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
/* we stop when we encounter a `def' or `]' */
if ( *cur == 'd' && cur + 3 < limit )
{
if ( cur[1] == 'e' &&
cur[2] == 'f' &&
IS_PS_DELIM( cur[3] ) )
{
FT_TRACE6(( "encoding end\n" ));
cur += 3;
break;
}
}
if ( *cur == ']' )
{
FT_TRACE6(( "encoding end\n" ));
cur++;
break;
}
/* check whether we've found an entry */
if ( ft_isdigit( *cur ) || only_immediates )
{
FT_Int charcode;
if ( only_immediates )
charcode = n;
else
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
/* protect against invalid charcode */
if ( cur == parser->root.cursor )
{
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
cur = parser->root.cursor;
if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.cursor >= limit )
return;
if ( parser->root.error )
return;
len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
if ( parser->root.error )
return;
char_table->elements[charcode][len] = '\0';
n++;
}
else if ( only_immediates )
{
/* Since the current position is not updated for */
/* immediates-only mode we would get an infinite loop if */
/* we don't do anything here. */
/* */
/* This encoding array is not valid according to the type1 */
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
return;
}
T1_Skip_Spaces( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding', */
/* `ExpertEncoding', or `ISOLatin1Encoding' */
else
{
if ( cur + 17 < limit &&
ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
else if ( cur + 15 < limit &&
ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
else if ( cur + 18 < limit &&
ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
parser->root.error = FT_ERR( Ignore );
}
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,611
|
parse_subrs( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
PS_Table table = &loader->subrs;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Int num_subrs;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
/* test for empty array */
if ( parser->root.cursor < parser->root.limit &&
*parser->root.cursor == '[' )
{
T1_Skip_PS_Token( parser );
T1_Skip_Spaces ( parser );
if ( parser->root.cursor >= parser->root.limit ||
*parser->root.cursor != ']' )
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
num_subrs = (FT_Int)T1_ToInt( parser );
/* position the parser right before the `dup' of the first subr */
T1_Skip_PS_Token( parser ); /* `array' */
if ( parser->root.error )
return;
T1_Skip_Spaces( parser );
/* initialize subrs array -- with synthetic fonts it is possible */
/* we get here twice */
if ( !loader->num_subrs )
{
error = psaux->ps_table_funcs->init( table, num_subrs, memory );
if ( error )
goto Fail;
}
/* the format is simple: */
/* */
/* `index' + binary data */
/* */
for (;;)
{
FT_Long idx, size;
FT_Byte* base;
/* If we are out of data, or if the next token isn't `dup', */
/* we are done. */
if ( parser->root.cursor + 4 >= parser->root.limit ||
ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
break;
T1_Skip_PS_Token( parser ); /* `dup' */
idx = T1_ToInt( parser );
if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* The binary string is followed by one token, e.g. `NP' */
/* (bound to `noaccess put') or by two separate tokens: */
/* `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 ( parser->root.cursor + 4 < parser->root.limit &&
ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
{
T1_Skip_PS_Token( parser ); /* skip `put' */
T1_Skip_Spaces ( parser );
}
/* with synthetic fonts it is possible we get here twice */
if ( loader->num_subrs )
continue;
/* some fonts use a value of -1 for lenIV to indicate that */
/* the charstrings are unencoded */
/* */
/* thanks to Tom Kacvinsky for pointing this out */
/* */
if ( face->type1.private_dict.lenIV >= 0 )
{
FT_Byte* temp;
/* 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 )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* t1_decrypt() shouldn't write to base -- make temporary copy */
if ( FT_ALLOC( temp, size ) )
goto Fail;
FT_MEM_COPY( temp, base, size );
psaux->t1_decrypt( temp, size, 4330 );
size -= face->type1.private_dict.lenIV;
error = T1_Add_Table( table, (FT_Int)idx,
temp + face->type1.private_dict.lenIV, size );
FT_FREE( temp );
}
else
error = T1_Add_Table( table, (FT_Int)idx, base, size );
if ( error )
goto Fail;
}
if ( !loader->num_subrs )
loader->num_subrs = num_subrs;
return;
Fail:
parser->root.error = error;
}
|
DoS Overflow
| 0
|
parse_subrs( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
PS_Table table = &loader->subrs;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Int num_subrs;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
/* test for empty array */
if ( parser->root.cursor < parser->root.limit &&
*parser->root.cursor == '[' )
{
T1_Skip_PS_Token( parser );
T1_Skip_Spaces ( parser );
if ( parser->root.cursor >= parser->root.limit ||
*parser->root.cursor != ']' )
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
num_subrs = (FT_Int)T1_ToInt( parser );
/* position the parser right before the `dup' of the first subr */
T1_Skip_PS_Token( parser ); /* `array' */
if ( parser->root.error )
return;
T1_Skip_Spaces( parser );
/* initialize subrs array -- with synthetic fonts it is possible */
/* we get here twice */
if ( !loader->num_subrs )
{
error = psaux->ps_table_funcs->init( table, num_subrs, memory );
if ( error )
goto Fail;
}
/* the format is simple: */
/* */
/* `index' + binary data */
/* */
for (;;)
{
FT_Long idx, size;
FT_Byte* base;
/* If we are out of data, or if the next token isn't `dup', */
/* we are done. */
if ( parser->root.cursor + 4 >= parser->root.limit ||
ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
break;
T1_Skip_PS_Token( parser ); /* `dup' */
idx = T1_ToInt( parser );
if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
/* The binary string is followed by one token, e.g. `NP' */
/* (bound to `noaccess put') or by two separate tokens: */
/* `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 ( parser->root.cursor + 4 < parser->root.limit &&
ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
{
T1_Skip_PS_Token( parser ); /* skip `put' */
T1_Skip_Spaces ( parser );
}
/* with synthetic fonts it is possible we get here twice */
if ( loader->num_subrs )
continue;
/* some fonts use a value of -1 for lenIV to indicate that */
/* the charstrings are unencoded */
/* */
/* thanks to Tom Kacvinsky for pointing this out */
/* */
if ( face->type1.private_dict.lenIV >= 0 )
{
FT_Byte* temp;
/* 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 )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* t1_decrypt() shouldn't write to base -- make temporary copy */
if ( FT_ALLOC( temp, size ) )
goto Fail;
FT_MEM_COPY( temp, base, size );
psaux->t1_decrypt( temp, size, 4330 );
size -= face->type1.private_dict.lenIV;
error = T1_Add_Table( table, (FT_Int)idx,
temp + face->type1.private_dict.lenIV, size );
FT_FREE( temp );
}
else
error = T1_Add_Table( table, (FT_Int)idx, base, size );
if ( error )
goto Fail;
}
if ( !loader->num_subrs )
loader->num_subrs = num_subrs;
return;
Fail:
parser->root.error = error;
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,612
|
t1_done_loader( T1_Loader loader )
{
T1_Parser parser = &loader->parser;
/* finalize tables */
T1_Release_Table( &loader->encoding_table );
T1_Release_Table( &loader->charstrings );
T1_Release_Table( &loader->glyph_names );
T1_Release_Table( &loader->swap_table );
T1_Release_Table( &loader->subrs );
/* finalize parser */
T1_Finalize_Parser( parser );
}
|
DoS Overflow
| 0
|
t1_done_loader( T1_Loader loader )
{
T1_Parser parser = &loader->parser;
/* finalize tables */
T1_Release_Table( &loader->encoding_table );
T1_Release_Table( &loader->charstrings );
T1_Release_Table( &loader->glyph_names );
T1_Release_Table( &loader->swap_table );
T1_Release_Table( &loader->subrs );
/* finalize parser */
T1_Finalize_Parser( parser );
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,613
|
t1_init_loader( T1_Loader loader,
T1_Face face )
{
FT_UNUSED( face );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
loader->num_glyphs = 0;
loader->num_chars = 0;
/* initialize the tables -- simply set their `init' field to 0 */
loader->encoding_table.init = 0;
loader->charstrings.init = 0;
loader->glyph_names.init = 0;
loader->subrs.init = 0;
loader->swap_table.init = 0;
loader->fontdata = 0;
loader->keywords_encountered = 0;
}
|
DoS Overflow
| 0
|
t1_init_loader( T1_Loader loader,
T1_Face face )
{
FT_UNUSED( face );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
loader->num_glyphs = 0;
loader->num_chars = 0;
/* initialize the tables -- simply set their `init' field to 0 */
loader->encoding_table.init = 0;
loader->charstrings.init = 0;
loader->glyph_names.init = 0;
loader->subrs.init = 0;
loader->swap_table.init = 0;
loader->fontdata = 0;
loader->keywords_encountered = 0;
}
|
@@ -1604,7 +1604,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-119
| null | null |
5,614
|
t42_is_space( FT_Byte c )
{
return ( c == ' ' || c == '\t' ||
c == '\r' || c == '\n' || c == '\f' ||
c == '\0' );
}
|
DoS Overflow
| 0
|
t42_is_space( FT_Byte c )
{
return ( c == ' ' || c == '\t' ||
c == '\r' || c == '\n' || c == '\f' ||
c == '\0' );
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,615
|
t42_loader_done( T42_Loader loader )
{
T42_Parser parser = &loader->parser;
/* finalize tables */
T1_Release_Table( &loader->encoding_table );
T1_Release_Table( &loader->charstrings );
T1_Release_Table( &loader->glyph_names );
T1_Release_Table( &loader->swap_table );
/* finalize parser */
t42_parser_done( parser );
}
|
DoS Overflow
| 0
|
t42_loader_done( T42_Loader loader )
{
T42_Parser parser = &loader->parser;
/* finalize tables */
T1_Release_Table( &loader->encoding_table );
T1_Release_Table( &loader->charstrings );
T1_Release_Table( &loader->glyph_names );
T1_Release_Table( &loader->swap_table );
/* finalize parser */
t42_parser_done( parser );
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,616
|
t42_loader_init( T42_Loader loader,
T42_Face face )
{
FT_UNUSED( face );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
loader->num_glyphs = 0;
loader->num_chars = 0;
/* initialize the tables -- simply set their `init' field to 0 */
loader->encoding_table.init = 0;
loader->charstrings.init = 0;
loader->glyph_names.init = 0;
}
|
DoS Overflow
| 0
|
t42_loader_init( T42_Loader loader,
T42_Face face )
{
FT_UNUSED( face );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
loader->num_glyphs = 0;
loader->num_chars = 0;
/* initialize the tables -- simply set their `init' field to 0 */
loader->encoding_table.init = 0;
loader->charstrings.init = 0;
loader->glyph_names.init = 0;
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,617
|
t42_parse_dict( T42_Face face,
T42_Loader loader,
FT_Byte* base,
FT_Long size )
{
T42_Parser parser = &loader->parser;
FT_Byte* limit;
FT_Int n_keywords = (FT_Int)( sizeof ( t42_keywords ) /
sizeof ( t42_keywords[0] ) );
parser->root.cursor = base;
parser->root.limit = base + size;
parser->root.error = FT_Err_Ok;
limit = parser->root.limit;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
FT_Byte* cur;
cur = parser->root.cursor;
/* look for `FontDirectory' which causes problems for some fonts */
if ( *cur == 'F' && cur + 25 < limit &&
ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
{
FT_Byte* cur2;
/* skip the `FontDirectory' keyword */
T1_Skip_PS_Token( parser );
T1_Skip_Spaces ( parser );
cur = cur2 = parser->root.cursor;
/* look up the `known' keyword */
while ( cur < limit )
{
if ( *cur == 'k' && cur + 5 < limit &&
ft_strncmp( (char*)cur, "known", 5 ) == 0 )
break;
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
T1_Skip_Spaces ( parser );
cur = parser->root.cursor;
}
if ( cur < limit )
{
T1_TokenRec token;
/* skip the `known' keyword and the token following it */
T1_Skip_PS_Token( parser );
T1_ToToken( parser, &token );
/* if the last token was an array, skip it! */
if ( token.type == T1_TOKEN_TYPE_ARRAY )
cur2 = parser->root.cursor;
}
parser->root.cursor = cur2;
}
/* look for immediates */
else if ( *cur == '/' && cur + 2 < limit )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
len = parser->root.cursor - cur;
if ( len > 0 && len < 22 && parser->root.cursor < limit )
{
int i;
/* now compare the immediate name to the keyword table */
/* loop through all known keywords */
for ( i = 0; i < n_keywords; i++ )
{
T1_Field keyword = (T1_Field)&t42_keywords[i];
FT_Byte *name = (FT_Byte*)keyword->ident;
if ( !name )
continue;
if ( cur[0] == name[0] &&
len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
ft_memcmp( cur, name, len ) == 0 )
{
/* we found it -- run the parsing callback! */
parser->root.error = t42_load_keyword( face,
loader,
keyword );
if ( parser->root.error )
return parser->root.error;
break;
}
}
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
}
T1_Skip_Spaces( parser );
}
Exit:
return parser->root.error;
}
|
DoS Overflow
| 0
|
t42_parse_dict( T42_Face face,
T42_Loader loader,
FT_Byte* base,
FT_Long size )
{
T42_Parser parser = &loader->parser;
FT_Byte* limit;
FT_Int n_keywords = (FT_Int)( sizeof ( t42_keywords ) /
sizeof ( t42_keywords[0] ) );
parser->root.cursor = base;
parser->root.limit = base + size;
parser->root.error = FT_Err_Ok;
limit = parser->root.limit;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
FT_Byte* cur;
cur = parser->root.cursor;
/* look for `FontDirectory' which causes problems for some fonts */
if ( *cur == 'F' && cur + 25 < limit &&
ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
{
FT_Byte* cur2;
/* skip the `FontDirectory' keyword */
T1_Skip_PS_Token( parser );
T1_Skip_Spaces ( parser );
cur = cur2 = parser->root.cursor;
/* look up the `known' keyword */
while ( cur < limit )
{
if ( *cur == 'k' && cur + 5 < limit &&
ft_strncmp( (char*)cur, "known", 5 ) == 0 )
break;
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
T1_Skip_Spaces ( parser );
cur = parser->root.cursor;
}
if ( cur < limit )
{
T1_TokenRec token;
/* skip the `known' keyword and the token following it */
T1_Skip_PS_Token( parser );
T1_ToToken( parser, &token );
/* if the last token was an array, skip it! */
if ( token.type == T1_TOKEN_TYPE_ARRAY )
cur2 = parser->root.cursor;
}
parser->root.cursor = cur2;
}
/* look for immediates */
else if ( *cur == '/' && cur + 2 < limit )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
len = parser->root.cursor - cur;
if ( len > 0 && len < 22 && parser->root.cursor < limit )
{
int i;
/* now compare the immediate name to the keyword table */
/* loop through all known keywords */
for ( i = 0; i < n_keywords; i++ )
{
T1_Field keyword = (T1_Field)&t42_keywords[i];
FT_Byte *name = (FT_Byte*)keyword->ident;
if ( !name )
continue;
if ( cur[0] == name[0] &&
len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
ft_memcmp( cur, name, len ) == 0 )
{
/* we found it -- run the parsing callback! */
parser->root.error = t42_load_keyword( face,
loader,
keyword );
if ( parser->root.error )
return parser->root.error;
break;
}
}
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
}
T1_Skip_Spaces( parser );
}
Exit:
return parser->root.error;
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,618
|
t42_parse_encoding( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
if ( cur >= limit )
{
FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* if we have a number or `[', the encoding is an array, */
/* and we must load it now */
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Bool only_immediates = 0;
/* read the number of entries in the encoding; should be 256 */
if ( *cur == '[' )
{
count = 256;
only_immediates = 1;
parser->root.cursor++;
}
else
count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit )
return;
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
if ( FT_NEW_ARRAY( encode->char_index, count ) ||
FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
parser->root.error = error;
return;
}
/* We need to `zero' out encoding_table.elements */
for ( n = 0; n < count; n++ )
{
char* notdef = (char *)".notdef";
T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
/* */
/* ... charcode /charname ... */
/* */
/* for each entry in our table. */
/* */
/* We simply look for a number followed by an immediate */
/* name. Note that this ignores correctly the sequence */
/* that is often seen in type42 fonts: */
/* */
/* 0 1 255 { 1 index exch /.notdef put } for dup */
/* */
/* used to clean the encoding array before anything else. */
/* */
/* Alternatively, if the array is directly given as */
/* */
/* /Encoding [ ... ] */
/* */
/* we only read immediates. */
n = 0;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
/* we stop when we encounter `def' or `]' */
if ( *cur == 'd' && cur + 3 < limit )
{
if ( cur[1] == 'e' &&
cur[2] == 'f' &&
t42_is_space( cur[3] ) )
{
FT_TRACE6(( "encoding end\n" ));
cur += 3;
break;
}
}
if ( *cur == ']' )
{
FT_TRACE6(( "encoding end\n" ));
cur++;
break;
}
/* check whether we have found an entry */
if ( ft_isdigit( *cur ) || only_immediates )
{
FT_Int charcode;
if ( only_immediates )
charcode = n;
else
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
}
cur = parser->root.cursor;
if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.cursor >= limit )
return;
if ( parser->root.error )
return;
len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
if ( parser->root.error )
return;
char_table->elements[charcode][len] = '\0';
n++;
}
else if ( only_immediates )
{
/* Since the current position is not updated for */
/* immediates-only mode we would get an infinite loop if */
/* we don't do anything here. */
/* */
/* This encoding array is not valid according to the type1 */
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
return;
}
T1_Skip_Spaces( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding', */
/* `ExpertEncoding', or `ISOLatin1Encoding' */
else
{
if ( cur + 17 < limit &&
ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
else if ( cur + 15 < limit &&
ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
else if ( cur + 18 < limit &&
ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
parser->root.error = FT_THROW( Ignore );
}
}
|
DoS Overflow
| 0
|
t42_parse_encoding( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
PSAux_Service psaux = (PSAux_Service)face->psaux;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
if ( cur >= limit )
{
FT_ERROR(( "t42_parse_encoding: out of bounds\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* if we have a number or `[', the encoding is an array, */
/* and we must load it now */
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Bool only_immediates = 0;
/* read the number of entries in the encoding; should be 256 */
if ( *cur == '[' )
{
count = 256;
only_immediates = 1;
parser->root.cursor++;
}
else
count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit )
return;
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
if ( FT_NEW_ARRAY( encode->char_index, count ) ||
FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
parser->root.error = error;
return;
}
/* We need to `zero' out encoding_table.elements */
for ( n = 0; n < count; n++ )
{
char* notdef = (char *)".notdef";
T1_Add_Table( char_table, n, notdef, 8 );
}
/* Now we need to read records of the form */
/* */
/* ... charcode /charname ... */
/* */
/* for each entry in our table. */
/* */
/* We simply look for a number followed by an immediate */
/* name. Note that this ignores correctly the sequence */
/* that is often seen in type42 fonts: */
/* */
/* 0 1 255 { 1 index exch /.notdef put } for dup */
/* */
/* used to clean the encoding array before anything else. */
/* */
/* Alternatively, if the array is directly given as */
/* */
/* /Encoding [ ... ] */
/* */
/* we only read immediates. */
n = 0;
T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
/* we stop when we encounter `def' or `]' */
if ( *cur == 'd' && cur + 3 < limit )
{
if ( cur[1] == 'e' &&
cur[2] == 'f' &&
t42_is_space( cur[3] ) )
{
FT_TRACE6(( "encoding end\n" ));
cur += 3;
break;
}
}
if ( *cur == ']' )
{
FT_TRACE6(( "encoding end\n" ));
cur++;
break;
}
/* check whether we have found an entry */
if ( ft_isdigit( *cur ) || only_immediates )
{
FT_Int charcode;
if ( only_immediates )
charcode = n;
else
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
}
cur = parser->root.cursor;
if ( cur + 2 < limit && *cur == '/' && n < count )
{
FT_PtrDist len;
cur++;
parser->root.cursor = cur;
T1_Skip_PS_Token( parser );
if ( parser->root.cursor >= limit )
return;
if ( parser->root.error )
return;
len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
if ( parser->root.error )
return;
char_table->elements[charcode][len] = '\0';
n++;
}
else if ( only_immediates )
{
/* Since the current position is not updated for */
/* immediates-only mode we would get an infinite loop if */
/* we don't do anything here. */
/* */
/* This encoding array is not valid according to the type1 */
/* specification (it might be an encoding for a CID type1 */
/* font, however), so we conclude that this font is NOT a */
/* type1 font. */
parser->root.error = FT_THROW( Unknown_File_Format );
return;
}
}
else
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
return;
}
T1_Skip_Spaces( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
parser->root.cursor = cur;
}
/* Otherwise, we should have either `StandardEncoding', */
/* `ExpertEncoding', or `ISOLatin1Encoding' */
else
{
if ( cur + 17 < limit &&
ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD;
else if ( cur + 15 < limit &&
ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT;
else if ( cur + 18 < limit &&
ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 )
face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1;
else
parser->root.error = FT_THROW( Ignore );
}
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,619
|
t42_parse_font_matrix( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
FT_Vector* offset = &face->type1.font_offset;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
FT_Int result;
result = T1_ToFixedArray( parser, 6, temp, 3 );
if ( result < 6 )
{
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
temp_scale = FT_ABS( temp[3] );
if ( temp_scale == 0 )
{
FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
{
temp[0] = FT_DivFix( temp[0], temp_scale );
temp[1] = FT_DivFix( temp[1], temp_scale );
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
matrix->yx = temp[1];
matrix->xy = temp[2];
matrix->yy = temp[3];
/* note that the offsets must be expressed in integer font units */
offset->x = temp[4] >> 16;
offset->y = temp[5] >> 16;
}
|
DoS Overflow
| 0
|
t42_parse_font_matrix( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
FT_Vector* offset = &face->type1.font_offset;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
FT_Int result;
result = T1_ToFixedArray( parser, 6, temp, 3 );
if ( result < 6 )
{
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
temp_scale = FT_ABS( temp[3] );
if ( temp_scale == 0 )
{
FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
{
temp[0] = FT_DivFix( temp[0], temp_scale );
temp[1] = FT_DivFix( temp[1], temp_scale );
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
matrix->yx = temp[1];
matrix->xy = temp[2];
matrix->yy = temp[3];
/* note that the offsets must be expressed in integer font units */
offset->x = temp[4] >> 16;
offset->y = temp[5] >> 16;
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,620
|
t42_parse_sfnts( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Memory memory = parser->root.memory;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
FT_ULong count, ttf_size = 0;
FT_Long n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
FT_Bool allocated = 0;
T42_Load_Status status;
/* The format is */
/* */
/* /sfnts [ <hexstring> <hexstring> ... ] def */
/* */
/* or */
/* */
/* /sfnts [ */
/* <num_bin_bytes> RD <binary data> */
/* <num_bin_bytes> RD <binary data> */
/* ... */
/* ] def */
/* */
/* with exactly one space after the `RD' token. */
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_Spaces( parser );
status = BEFORE_START;
string_size = 0;
old_string_size = 0;
count = 0;
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
if ( *cur == ']' )
{
parser->root.cursor++;
goto Exit;
}
else if ( *cur == '<' )
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
/* don't include delimiters */
string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
goto Fail;
allocated = 1;
parser->root.cursor = cur;
(void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
old_string_size = string_size;
string_size = real_size;
}
else if ( ft_isdigit( *cur ) )
{
if ( allocated )
{
FT_ERROR(( "t42_parse_sfnts: "
"can't handle mixed binary and hex strings\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
string_size = T1_ToInt( parser );
if ( string_size < 0 )
{
FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_PS_Token( parser ); /* `RD' */
if ( parser->root.error )
return;
string_buf = parser->root.cursor + 1; /* one space after `RD' */
if ( limit - parser->root.cursor < string_size )
{
FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
else
parser->root.cursor += string_size + 1;
}
if ( !string_buf )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* A string can have a trailing zero (odd) byte for padding. */
/* Ignore it. */
if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
string_size--;
if ( !string_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
for ( n = 0; n < string_size; n++ )
{
switch ( status )
{
case BEFORE_START:
/* load offset table, 12 bytes */
if ( count < 12 )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
status = BEFORE_TABLE_DIR;
ttf_size = 12 + 16 * num_tables;
if ( FT_REALLOC( face->ttf_data, 12, ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
if ( count < ttf_size )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
int i;
FT_ULong len;
for ( i = 0; i < num_tables; i++ )
{
FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
len = FT_PEEK_ULONG( p );
/* Pad to a 4-byte boundary length */
ttf_size += ( len + 3 ) & ~3;
}
status = OTHER_TABLES;
face->ttf_size = ttf_size;
/* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
if ( count >= ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
face->ttf_data[count++] = string_buf[n];
}
}
T1_Skip_Spaces( parser );
}
/* if control reaches this point, the format was not valid */
error = FT_THROW( Invalid_File_Format );
Fail:
parser->root.error = error;
Exit:
if ( allocated )
FT_FREE( string_buf );
}
|
DoS Overflow
| 0
|
t42_parse_sfnts( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Memory memory = parser->root.memory;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
FT_ULong count, ttf_size = 0;
FT_Long n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
FT_Bool allocated = 0;
T42_Load_Status status;
/* The format is */
/* */
/* /sfnts [ <hexstring> <hexstring> ... ] def */
/* */
/* or */
/* */
/* /sfnts [ */
/* <num_bin_bytes> RD <binary data> */
/* <num_bin_bytes> RD <binary data> */
/* ... */
/* ] def */
/* */
/* with exactly one space after the `RD' token. */
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_Spaces( parser );
status = BEFORE_START;
string_size = 0;
old_string_size = 0;
count = 0;
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
if ( *cur == ']' )
{
parser->root.cursor++;
goto Exit;
}
else if ( *cur == '<' )
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
/* don't include delimiters */
string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
goto Fail;
allocated = 1;
parser->root.cursor = cur;
(void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
old_string_size = string_size;
string_size = real_size;
}
else if ( ft_isdigit( *cur ) )
{
if ( allocated )
{
FT_ERROR(( "t42_parse_sfnts: "
"can't handle mixed binary and hex strings\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
string_size = T1_ToInt( parser );
if ( string_size < 0 )
{
FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_PS_Token( parser ); /* `RD' */
if ( parser->root.error )
return;
string_buf = parser->root.cursor + 1; /* one space after `RD' */
if ( limit - parser->root.cursor < string_size )
{
FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
else
parser->root.cursor += string_size + 1;
}
if ( !string_buf )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* A string can have a trailing zero (odd) byte for padding. */
/* Ignore it. */
if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
string_size--;
if ( !string_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
for ( n = 0; n < string_size; n++ )
{
switch ( status )
{
case BEFORE_START:
/* load offset table, 12 bytes */
if ( count < 12 )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
status = BEFORE_TABLE_DIR;
ttf_size = 12 + 16 * num_tables;
if ( FT_REALLOC( face->ttf_data, 12, ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
if ( count < ttf_size )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
int i;
FT_ULong len;
for ( i = 0; i < num_tables; i++ )
{
FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
len = FT_PEEK_ULONG( p );
/* Pad to a 4-byte boundary length */
ttf_size += ( len + 3 ) & ~3;
}
status = OTHER_TABLES;
face->ttf_size = ttf_size;
/* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
if ( count >= ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
face->ttf_data[count++] = string_buf[n];
}
}
T1_Skip_Spaces( parser );
}
/* if control reaches this point, the format was not valid */
error = FT_THROW( Invalid_File_Format );
Fail:
parser->root.error = error;
Exit:
if ( allocated )
FT_FREE( string_buf );
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,621
|
t42_parser_init( T42_Parser parser,
FT_Stream stream,
FT_Memory memory,
PSAux_Service psaux )
{
FT_Error error = FT_Err_Ok;
FT_Long size;
psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream;
parser->base_len = 0;
parser->base_dict = 0;
parser->in_memory = 0;
/*******************************************************************/
/* */
/* Here a short summary of what is going on: */
/* */
/* When creating a new Type 42 parser, we try to locate and load */
/* the base dictionary, loading the whole font into memory. */
/* */
/* When `loading' the base dictionary, we only set up pointers */
/* in the case of a memory-based stream. Otherwise, we allocate */
/* and load the base dictionary in it. */
/* */
/* parser->in_memory is set if we have a memory stream. */
/* */
if ( FT_STREAM_SEEK( 0L ) ||
FT_FRAME_ENTER( 17 ) )
goto Exit;
if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 )
{
FT_TRACE2(( " not a Type42 font\n" ));
error = FT_THROW( Unknown_File_Format );
}
FT_FRAME_EXIT();
if ( error || FT_STREAM_SEEK( 0 ) )
goto Exit;
size = stream->size;
/* now, try to load `size' bytes of the `base' dictionary we */
/* found previously */
/* if it is a memory-based resource, set up pointers */
if ( !stream->read )
{
parser->base_dict = (FT_Byte*)stream->base + stream->pos;
parser->base_len = size;
parser->in_memory = 1;
/* check that the `size' field is valid */
if ( FT_STREAM_SKIP( size ) )
goto Exit;
}
else
{
/* read segment in memory */
if ( FT_ALLOC( parser->base_dict, size ) ||
FT_STREAM_READ( parser->base_dict, size ) )
goto Exit;
parser->base_len = size;
}
parser->root.base = parser->base_dict;
parser->root.cursor = parser->base_dict;
parser->root.limit = parser->root.cursor + parser->base_len;
Exit:
if ( error && !parser->in_memory )
FT_FREE( parser->base_dict );
return error;
}
|
DoS Overflow
| 0
|
t42_parser_init( T42_Parser parser,
FT_Stream stream,
FT_Memory memory,
PSAux_Service psaux )
{
FT_Error error = FT_Err_Ok;
FT_Long size;
psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream;
parser->base_len = 0;
parser->base_dict = 0;
parser->in_memory = 0;
/*******************************************************************/
/* */
/* Here a short summary of what is going on: */
/* */
/* When creating a new Type 42 parser, we try to locate and load */
/* the base dictionary, loading the whole font into memory. */
/* */
/* When `loading' the base dictionary, we only set up pointers */
/* in the case of a memory-based stream. Otherwise, we allocate */
/* and load the base dictionary in it. */
/* */
/* parser->in_memory is set if we have a memory stream. */
/* */
if ( FT_STREAM_SEEK( 0L ) ||
FT_FRAME_ENTER( 17 ) )
goto Exit;
if ( ft_memcmp( stream->cursor, "%!PS-TrueTypeFont", 17 ) != 0 )
{
FT_TRACE2(( " not a Type42 font\n" ));
error = FT_THROW( Unknown_File_Format );
}
FT_FRAME_EXIT();
if ( error || FT_STREAM_SEEK( 0 ) )
goto Exit;
size = stream->size;
/* now, try to load `size' bytes of the `base' dictionary we */
/* found previously */
/* if it is a memory-based resource, set up pointers */
if ( !stream->read )
{
parser->base_dict = (FT_Byte*)stream->base + stream->pos;
parser->base_len = size;
parser->in_memory = 1;
/* check that the `size' field is valid */
if ( FT_STREAM_SKIP( size ) )
goto Exit;
}
else
{
/* read segment in memory */
if ( FT_ALLOC( parser->base_dict, size ) ||
FT_STREAM_READ( parser->base_dict, size ) )
goto Exit;
parser->base_len = size;
}
parser->root.base = parser->base_dict;
parser->root.cursor = parser->base_dict;
parser->root.limit = parser->root.cursor + parser->base_len;
Exit:
if ( error && !parser->in_memory )
FT_FREE( parser->base_dict );
return error;
}
|
@@ -858,7 +858,7 @@
FT_PtrDist len;
- if ( cur + 1 >= limit )
+ if ( cur + 2 >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
|
CWE-119
| null | null |
5,622
|
t42_parse_sfnts( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Memory memory = parser->root.memory;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
FT_ULong count;
FT_Long n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
FT_Bool allocated = 0;
T42_Load_Status status;
/* The format is */
/* */
/* /sfnts [ <hexstring> <hexstring> ... ] def */
/* */
/* or */
/* */
/* /sfnts [ */
/* <num_bin_bytes> RD <binary data> */
/* <num_bin_bytes> RD <binary data> */
/* ... */
/* ] def */
/* */
/* with exactly one space after the `RD' token. */
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_Spaces( parser );
status = BEFORE_START;
string_size = 0;
old_string_size = 0;
count = 0;
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
if ( *cur == ']' )
{
parser->root.cursor++;
goto Exit;
}
else if ( *cur == '<' )
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
/* don't include delimiters */
string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
goto Fail;
allocated = 1;
parser->root.cursor = cur;
(void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
old_string_size = string_size;
string_size = real_size;
}
else if ( ft_isdigit( *cur ) )
{
if ( allocated )
{
FT_ERROR(( "t42_parse_sfnts: "
"can't handle mixed binary and hex strings\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
string_size = T1_ToInt( parser );
if ( string_size < 0 )
{
FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_PS_Token( parser ); /* `RD' */
if ( parser->root.error )
return;
string_buf = parser->root.cursor + 1; /* one space after `RD' */
if ( limit - parser->root.cursor < string_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
else
parser->root.cursor += string_size + 1;
}
if ( !string_buf )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* A string can have a trailing zero (odd) byte for padding. */
/* Ignore it. */
if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
string_size--;
if ( !string_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
for ( n = 0; n < string_size; n++ )
{
switch ( status )
{
case BEFORE_START:
/* load offset table, 12 bytes */
if ( count < 12 )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
status = BEFORE_TABLE_DIR;
face->ttf_size = 12 + 16 * num_tables;
if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
if ( count < face->ttf_size )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
int i;
FT_ULong len;
for ( i = 0; i < num_tables; i++ )
{
FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
len = FT_PEEK_ULONG( p );
/* Pad to a 4-byte boundary length */
face->ttf_size += ( len + 3 ) & ~3;
}
status = OTHER_TABLES;
/* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
face->ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
if ( count >= face->ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
face->ttf_data[count++] = string_buf[n];
}
}
T1_Skip_Spaces( parser );
}
/* if control reaches this point, the format was not valid */
error = FT_THROW( Invalid_File_Format );
Fail:
parser->root.error = error;
Exit:
if ( allocated )
FT_FREE( string_buf );
}
|
DoS Overflow
| 0
|
t42_parse_sfnts( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Memory memory = parser->root.memory;
FT_Byte* cur;
FT_Byte* limit = parser->root.limit;
FT_Error error;
FT_Int num_tables = 0;
FT_ULong count;
FT_Long n, string_size, old_string_size, real_size;
FT_Byte* string_buf = NULL;
FT_Bool allocated = 0;
T42_Load_Status status;
/* The format is */
/* */
/* /sfnts [ <hexstring> <hexstring> ... ] def */
/* */
/* or */
/* */
/* /sfnts [ */
/* <num_bin_bytes> RD <binary data> */
/* <num_bin_bytes> RD <binary data> */
/* ... */
/* ] def */
/* */
/* with exactly one space after the `RD' token. */
T1_Skip_Spaces( parser );
if ( parser->root.cursor >= limit || *parser->root.cursor++ != '[' )
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_Spaces( parser );
status = BEFORE_START;
string_size = 0;
old_string_size = 0;
count = 0;
while ( parser->root.cursor < limit )
{
cur = parser->root.cursor;
if ( *cur == ']' )
{
parser->root.cursor++;
goto Exit;
}
else if ( *cur == '<' )
{
T1_Skip_PS_Token( parser );
if ( parser->root.error )
goto Exit;
/* don't include delimiters */
string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
goto Fail;
allocated = 1;
parser->root.cursor = cur;
(void)T1_ToBytes( parser, string_buf, string_size, &real_size, 1 );
old_string_size = string_size;
string_size = real_size;
}
else if ( ft_isdigit( *cur ) )
{
if ( allocated )
{
FT_ERROR(( "t42_parse_sfnts: "
"can't handle mixed binary and hex strings\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
string_size = T1_ToInt( parser );
if ( string_size < 0 )
{
FT_ERROR(( "t42_parse_sfnts: invalid string size\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
T1_Skip_PS_Token( parser ); /* `RD' */
if ( parser->root.error )
return;
string_buf = parser->root.cursor + 1; /* one space after `RD' */
if ( limit - parser->root.cursor < string_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
else
parser->root.cursor += string_size + 1;
}
if ( !string_buf )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* A string can have a trailing zero (odd) byte for padding. */
/* Ignore it. */
if ( ( string_size & 1 ) && string_buf[string_size - 1] == 0 )
string_size--;
if ( !string_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid string\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
for ( n = 0; n < string_size; n++ )
{
switch ( status )
{
case BEFORE_START:
/* load offset table, 12 bytes */
if ( count < 12 )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
status = BEFORE_TABLE_DIR;
face->ttf_size = 12 + 16 * num_tables;
if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
goto Fail;
}
/* fall through */
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
if ( count < face->ttf_size )
{
face->ttf_data[count++] = string_buf[n];
continue;
}
else
{
int i;
FT_ULong len;
for ( i = 0; i < num_tables; i++ )
{
FT_Byte* p = face->ttf_data + 12 + 16 * i + 12;
len = FT_PEEK_ULONG( p );
/* Pad to a 4-byte boundary length */
face->ttf_size += ( len + 3 ) & ~3;
}
status = OTHER_TABLES;
/* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
face->ttf_size + 1 ) )
goto Fail;
}
/* fall through */
case OTHER_TABLES:
/* all other tables are just copied */
if ( count >= face->ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
face->ttf_data[count++] = string_buf[n];
}
}
T1_Skip_Spaces( parser );
}
/* if control reaches this point, the format was not valid */
error = FT_THROW( Invalid_File_Format );
Fail:
parser->root.error = error;
Exit:
if ( allocated )
FT_FREE( string_buf );
}
|
@@ -849,6 +849,12 @@
break;
T1_Skip_PS_Token( parser );
+ if ( parser->root.cursor >= limit )
+ {
+ FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
if ( parser->root.error )
return;
|
CWE-119
| null | null |
5,623
|
tt_cmap10_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 10;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap10_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 10;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,624
|
tt_cmap10_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_ULong length, count;
if ( table + 20 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
p = table + 16;
count = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 20 + count * 2 ? */
length < 20 ||
( length - 20 ) / 2 < count )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt gindex;
for ( ; count > 0; count-- )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap10_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_ULong length, count;
if ( table + 20 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
p = table + 16;
count = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 20 + count * 2 ? */
length < 20 ||
( length - 20 ) / 2 < count )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt gindex;
for ( ; count > 0; count-- )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,625
|
tt_cmap12_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap12_char_map_binary( cmap, &char_code, 0 );
}
|
DoS Overflow
| 0
|
tt_cmap12_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap12_char_map_binary( cmap, &char_code, 0 );
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,626
|
tt_cmap12_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap12 cmap12 = (TT_CMap12)cmap;
FT_ULong gindex;
if ( cmap12->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap12->valid && cmap12->cur_charcode == *pchar_code )
{
tt_cmap12_next( cmap12 );
if ( cmap12->valid )
{
gindex = cmap12->cur_gindex;
/* XXX: check cur_charcode overflow is expected */
if ( gindex )
*pchar_code = (FT_UInt32)cmap12->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 );
/* XXX: check gindex overflow is expected */
return (FT_UInt32)gindex;
}
|
DoS Overflow
| 0
|
tt_cmap12_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap12 cmap12 = (TT_CMap12)cmap;
FT_ULong gindex;
if ( cmap12->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap12->valid && cmap12->cur_charcode == *pchar_code )
{
tt_cmap12_next( cmap12 );
if ( cmap12->valid )
{
gindex = cmap12->cur_gindex;
/* XXX: check cur_charcode overflow is expected */
if ( gindex )
*pchar_code = (FT_UInt32)cmap12->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 );
/* XXX: check gindex overflow is expected */
return (FT_UInt32)gindex;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,627
|
tt_cmap12_init( TT_CMap12 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap12_init( TT_CMap12 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,628
|
tt_cmap12_next( TT_CMap12 cmap )
{
FT_Byte* p;
FT_ULong start, end, start_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
for ( ; char_code <= end; char_code++ )
{
gindex = (FT_UInt)( start_id + char_code - start );
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
|
DoS Overflow
| 0
|
tt_cmap12_next( TT_CMap12 cmap )
{
FT_Byte* p;
FT_ULong start, end, start_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
for ( ; char_code <= end; char_code++ )
{
gindex = (FT_UInt)( start_id + char_code - start );
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,629
|
tt_cmap12_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 16 + 12 * num_groups ? */
length < 16 ||
( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, start_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt32 d = end - start;
/* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap12_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 16 + 12 * num_groups ? */
length < 16 ||
( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, start_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt32 d = end - start;
/* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,630
|
tt_cmap13_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap13_char_map_binary( cmap, &char_code, 0 );
}
|
DoS Overflow
| 0
|
tt_cmap13_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap13_char_map_binary( cmap, &char_code, 0 );
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,631
|
tt_cmap13_char_map_binary( TT_CMap cmap,
FT_UInt32* pchar_code,
FT_Bool next )
{
FT_UInt gindex = 0;
FT_Byte* p = cmap->data + 12;
FT_UInt32 num_groups = TT_PEEK_ULONG( p );
FT_UInt32 char_code = *pchar_code;
FT_UInt32 start, end;
FT_UInt32 max, min, mid;
if ( !num_groups )
return 0;
/* make compiler happy */
mid = num_groups;
end = 0xFFFFFFFFUL;
if ( next )
char_code++;
min = 0;
max = num_groups;
/* binary search */
while ( min < max )
{
mid = ( min + max ) >> 1;
p = cmap->data + 16 + 12 * mid;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
if ( char_code < start )
max = mid;
else if ( char_code > end )
min = mid + 1;
else
{
gindex = (FT_UInt)TT_PEEK_ULONG( p );
break;
}
}
if ( next )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
/* if `char_code' is not in any group, then `mid' is */
/* the group nearest to `char_code' */
if ( char_code > end )
{
mid++;
if ( mid == num_groups )
return 0;
}
cmap13->valid = 1;
cmap13->cur_charcode = char_code;
cmap13->cur_group = mid;
if ( !gindex )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
gindex = cmap13->cur_gindex;
}
else
cmap13->cur_gindex = gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
return gindex;
}
|
DoS Overflow
| 0
|
tt_cmap13_char_map_binary( TT_CMap cmap,
FT_UInt32* pchar_code,
FT_Bool next )
{
FT_UInt gindex = 0;
FT_Byte* p = cmap->data + 12;
FT_UInt32 num_groups = TT_PEEK_ULONG( p );
FT_UInt32 char_code = *pchar_code;
FT_UInt32 start, end;
FT_UInt32 max, min, mid;
if ( !num_groups )
return 0;
/* make compiler happy */
mid = num_groups;
end = 0xFFFFFFFFUL;
if ( next )
char_code++;
min = 0;
max = num_groups;
/* binary search */
while ( min < max )
{
mid = ( min + max ) >> 1;
p = cmap->data + 16 + 12 * mid;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
if ( char_code < start )
max = mid;
else if ( char_code > end )
min = mid + 1;
else
{
gindex = (FT_UInt)TT_PEEK_ULONG( p );
break;
}
}
if ( next )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
/* if `char_code' is not in any group, then `mid' is */
/* the group nearest to `char_code' */
if ( char_code > end )
{
mid++;
if ( mid == num_groups )
return 0;
}
cmap13->valid = 1;
cmap13->cur_charcode = char_code;
cmap13->cur_group = mid;
if ( !gindex )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
gindex = cmap13->cur_gindex;
}
else
cmap13->cur_gindex = gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
return gindex;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,632
|
tt_cmap13_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
FT_UInt gindex;
if ( cmap13->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
{
gindex = cmap13->cur_gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 );
return gindex;
}
|
DoS Overflow
| 0
|
tt_cmap13_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
FT_UInt gindex;
if ( cmap13->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
{
gindex = cmap13->cur_gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 );
return gindex;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,633
|
tt_cmap13_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 13;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap13_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 13;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,634
|
tt_cmap13_init( TT_CMap13 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap13_init( TT_CMap13 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,635
|
tt_cmap13_next( TT_CMap13 cmap )
{
FT_Byte* p;
FT_ULong start, end, glyph_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
if ( char_code <= end )
{
gindex = (FT_UInt)glyph_id;
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
|
DoS Overflow
| 0
|
tt_cmap13_next( TT_CMap13 cmap )
{
FT_Byte* p;
FT_ULong start, end, glyph_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
if ( char_code <= end )
{
gindex = (FT_UInt)glyph_id;
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,636
|
tt_cmap13_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 16 + 12 * num_groups ? */
length < 16 ||
( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, glyph_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap13_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 16 + 12 * num_groups ? */
length < 16 ||
( length - 16 ) / 12 < num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, glyph_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,637
|
tt_cmap14_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_UNUSED( cmap );
FT_UNUSED( char_code );
/* This can't happen */
return 0;
}
|
DoS Overflow
| 0
|
tt_cmap14_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_UNUSED( cmap );
FT_UNUSED( char_code );
/* This can't happen */
return 0;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,638
|
tt_cmap14_char_map_def_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numRanges = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numRanges;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 4 * mid;
FT_ULong start = TT_NEXT_UINT24( p );
FT_UInt cnt = FT_NEXT_BYTE( p );
if ( char_code < start )
max = mid;
else if ( char_code > start+cnt )
min = mid + 1;
else
return TRUE;
}
return FALSE;
}
|
DoS Overflow
| 0
|
tt_cmap14_char_map_def_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numRanges = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numRanges;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 4 * mid;
FT_ULong start = TT_NEXT_UINT24( p );
FT_UInt cnt = FT_NEXT_BYTE( p );
if ( char_code < start )
max = mid;
else if ( char_code > start+cnt )
min = mid + 1;
else
return TRUE;
}
return FALSE;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,639
|
tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
|
DoS Overflow
| 0
|
tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,640
|
tt_cmap14_char_var_isdefault( TT_CMap cmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return -1;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
return 1;
if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode ) != 0 )
return 0;
return -1;
}
|
DoS Overflow
| 0
|
tt_cmap14_char_var_isdefault( TT_CMap cmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return -1;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
return 1;
if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode ) != 0 )
return 0;
return -1;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,641
|
tt_cmap14_char_variants( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 charCode )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* q;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
{
FT_UInt32 varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff,
charCode ) ) ||
( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charCode ) != 0 ) )
{
q[0] = varSel;
q++;
}
}
q[0] = 0;
return cmap14->results;
}
|
DoS Overflow
| 0
|
tt_cmap14_char_variants( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 charCode )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* q;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
{
FT_UInt32 varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff,
charCode ) ) ||
( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charCode ) != 0 ) )
{
q[0] = varSel;
q++;
}
}
q[0] = 0;
return cmap14->results;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,642
|
tt_cmap14_def_char_count( FT_Byte *p )
{
FT_UInt32 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
FT_UInt tot = 0;
p += 3; /* point to the first `cnt' field */
for ( ; numRanges > 0; numRanges-- )
{
tot += 1 + p[0];
p += 4;
}
return tot;
}
|
DoS Overflow
| 0
|
tt_cmap14_def_char_count( FT_Byte *p )
{
FT_UInt32 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
FT_UInt tot = 0;
p += 3; /* point to the first `cnt' field */
for ( ; numRanges > 0; numRanges-- )
{
tot += 1 + p[0];
p += 4;
}
return tot;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,643
|
tt_cmap14_done( TT_CMap14 cmap )
{
FT_Memory memory = cmap->memory;
cmap->max_results = 0;
if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
|
DoS Overflow
| 0
|
tt_cmap14_done( TT_CMap14 cmap )
{
FT_Memory memory = cmap->memory;
cmap->max_results = 0;
if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,644
|
tt_cmap14_ensure( TT_CMap14 cmap,
FT_UInt32 num_results,
FT_Memory memory )
{
FT_UInt32 old_max = cmap->max_results;
FT_Error error = FT_Err_Ok;
if ( num_results > cmap->max_results )
{
cmap->memory = memory;
if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
return error;
cmap->max_results = num_results;
}
return error;
}
|
DoS Overflow
| 0
|
tt_cmap14_ensure( TT_CMap14 cmap,
FT_UInt32 num_results,
FT_Memory memory )
{
FT_UInt32 old_max = cmap->max_results;
FT_Error error = FT_Err_Ok;
if ( num_results > cmap->max_results )
{
cmap->memory = memory;
if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
return error;
cmap->max_results = num_results;
}
return error;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,645
|
tt_cmap14_find_variant( FT_Byte *base,
FT_UInt32 variantCode )
{
FT_UInt32 numVar = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numVar;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 11 * mid;
FT_ULong varSel = TT_NEXT_UINT24( p );
if ( variantCode < varSel )
max = mid;
else if ( variantCode > varSel )
min = mid + 1;
else
return p;
}
return NULL;
}
|
DoS Overflow
| 0
|
tt_cmap14_find_variant( FT_Byte *base,
FT_UInt32 variantCode )
{
FT_UInt32 numVar = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numVar;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 11 * mid;
FT_ULong varSel = TT_NEXT_UINT24( p );
if ( variantCode < varSel )
max = mid;
else if ( variantCode > varSel )
min = mid + 1;
else
return p;
}
return NULL;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,646
|
tt_cmap14_get_def_chars( TT_CMap cmap,
FT_Byte* p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt cnt;
FT_UInt32* q;
cnt = tt_cmap14_def_char_count( p );
numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
} while ( --cnt != 0 );
}
q[0] = 0;
return cmap14->results;
}
|
DoS Overflow
| 0
|
tt_cmap14_get_def_chars( TT_CMap cmap,
FT_Byte* p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt cnt;
FT_UInt32* q;
cnt = tt_cmap14_def_char_count( p );
numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
} while ( --cnt != 0 );
}
q[0] = 0;
return cmap14->results;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,647
|
tt_cmap14_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_UNUSED( cmap );
cmap_info->format = 14;
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap14_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_UNUSED( cmap );
cmap_info->format = 14;
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,648
|
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numMappings;
FT_UInt i;
FT_UInt32 *ret;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
for ( i = 0; i < numMappings; ++i )
{
ret[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
ret[i] = 0;
return ret;
}
|
DoS Overflow
| 0
|
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numMappings;
FT_UInt i;
FT_UInt32 *ret;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
for ( i = 0; i < numMappings; ++i )
{
ret[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
ret[i] = 0;
return ret;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,649
|
tt_cmap14_init( TT_CMap14 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table );
cmap->max_results = 0;
cmap->results = NULL;
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap14_init( TT_CMap14 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table );
cmap->max_results = 0;
cmap->results = NULL;
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,650
|
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_selectors;
if ( table + 2 + 4 + 4 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
length = TT_NEXT_ULONG( p );
num_selectors = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 10 + 11 * num_selectors ? */
length < 10 ||
( length - 10 ) / 11 < num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
{
/* we start lastVarSel at 1 because a variant selector value of 0
* isn't valid.
*/
FT_ULong n, lastVarSel = 1;
for ( n = 0; n < num_selectors; n++ )
{
FT_ULong varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( defOff >= length || nondefOff >= length )
FT_INVALID_TOO_SHORT;
if ( varSel < lastVarSel )
FT_INVALID_DATA;
lastVarSel = varSel + 1;
/* check the default table (these glyphs should be reached */
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
FT_Byte* defp = table + defOff;
FT_ULong numRanges = TT_NEXT_ULONG( defp );
FT_ULong i;
FT_ULong lastBase = 0;
/* defp + numRanges * 4 > valid->limit ? */
if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
{
FT_ULong base = TT_NEXT_UINT24( defp );
FT_ULong cnt = FT_NEXT_BYTE( defp );
if ( base + cnt >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( base < lastBase )
FT_INVALID_DATA;
lastBase = base + cnt + 1U;
}
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 )
{
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
/* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
if ( uni >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( uni < lastUni )
FT_INVALID_DATA;
lastUni = uni + 1U;
if ( valid->level >= FT_VALIDATE_TIGHT &&
gid >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_selectors;
if ( table + 2 + 4 + 4 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
length = TT_NEXT_ULONG( p );
num_selectors = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
/* length < 10 + 11 * num_selectors ? */
length < 10 ||
( length - 10 ) / 11 < num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
{
/* we start lastVarSel at 1 because a variant selector value of 0
* isn't valid.
*/
FT_ULong n, lastVarSel = 1;
for ( n = 0; n < num_selectors; n++ )
{
FT_ULong varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( defOff >= length || nondefOff >= length )
FT_INVALID_TOO_SHORT;
if ( varSel < lastVarSel )
FT_INVALID_DATA;
lastVarSel = varSel + 1;
/* check the default table (these glyphs should be reached */
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
FT_Byte* defp = table + defOff;
FT_ULong numRanges = TT_NEXT_ULONG( defp );
FT_ULong i;
FT_ULong lastBase = 0;
/* defp + numRanges * 4 > valid->limit ? */
if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
{
FT_ULong base = TT_NEXT_UINT24( defp );
FT_ULong cnt = FT_NEXT_BYTE( defp );
if ( base + cnt >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( base < lastBase )
FT_INVALID_DATA;
lastBase = base + cnt + 1U;
}
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 )
{
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
/* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
if ( uni >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( uni < lastUni )
FT_INVALID_DATA;
lastUni = uni + 1U;
if ( valid->level >= FT_VALIDATE_TIGHT &&
gid >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,651
|
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* result;
FT_UInt32 i;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
for ( i = 0; i < count; ++i )
{
result[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 8;
}
result[i] = 0;
return result;
}
|
DoS Overflow
| 0
|
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* result;
FT_UInt32 i;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
for ( i = 0; i < count; ++i )
{
result[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 8;
}
result[i] = 0;
return result;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,652
|
tt_cmap8_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 8;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap8_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 8;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,653
|
tt_cmap8_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_Byte* is32;
FT_UInt32 length;
FT_UInt32 num_groups;
if ( table + 16 + 8192 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
if ( length > (FT_UInt32)( valid->limit - table ) || length < 8192 + 16 )
FT_INVALID_TOO_SHORT;
is32 = table + 12;
p = is32 + 8192; /* skip `is32' array */
num_groups = TT_NEXT_ULONG( p );
/* p + num_groups * 12 > valid->limit ? */
if ( num_groups > (FT_UInt32)( valid->limit - p ) / 12 )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_UInt32 n, start, end, start_id, count, last = 0;
for ( n = 0; n < num_groups; n++ )
{
FT_UInt hi, lo;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt32 d = end - start;
/* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
count = (FT_UInt32)( end - start + 1 );
if ( start & ~0xFFFFU )
{
/* start_hi != 0; check that is32[i] is 1 for each i in */
/* the `hi' and `lo' of the range [start..end] */
for ( ; count > 0; count--, start++ )
{
hi = (FT_UInt)( start >> 16 );
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 )
FT_INVALID_DATA;
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 )
FT_INVALID_DATA;
}
}
else
{
/* start_hi == 0; check that is32[i] is 0 for each i in */
/* the range [start..end] */
/* end_hi cannot be != 0! */
if ( end & ~0xFFFFU )
FT_INVALID_DATA;
for ( ; count > 0; count--, start++ )
{
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
FT_INVALID_DATA;
}
}
}
last = end;
}
}
return FT_Err_Ok;
}
|
DoS Overflow
| 0
|
tt_cmap8_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_Byte* is32;
FT_UInt32 length;
FT_UInt32 num_groups;
if ( table + 16 + 8192 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
if ( length > (FT_UInt32)( valid->limit - table ) || length < 8192 + 16 )
FT_INVALID_TOO_SHORT;
is32 = table + 12;
p = is32 + 8192; /* skip `is32' array */
num_groups = TT_NEXT_ULONG( p );
/* p + num_groups * 12 > valid->limit ? */
if ( num_groups > (FT_UInt32)( valid->limit - p ) / 12 )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_UInt32 n, start, end, start_id, count, last = 0;
for ( n = 0; n < num_groups; n++ )
{
FT_UInt hi, lo;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt32 d = end - start;
/* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
if ( d > TT_VALID_GLYPH_COUNT( valid ) ||
start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
FT_INVALID_GLYPH_ID;
count = (FT_UInt32)( end - start + 1 );
if ( start & ~0xFFFFU )
{
/* start_hi != 0; check that is32[i] is 1 for each i in */
/* the `hi' and `lo' of the range [start..end] */
for ( ; count > 0; count--, start++ )
{
hi = (FT_UInt)( start >> 16 );
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 )
FT_INVALID_DATA;
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 )
FT_INVALID_DATA;
}
}
else
{
/* start_hi == 0; check that is32[i] is 0 for each i in */
/* the range [start..end] */
/* end_hi cannot be != 0! */
if ( end & ~0xFFFFU )
FT_INVALID_DATA;
for ( ; count > 0; count--, start++ )
{
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
FT_INVALID_DATA;
}
}
}
last = end;
}
}
return FT_Err_Ok;
}
|
@@ -845,9 +845,6 @@
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
- if ( length < 16 )
- FT_INVALID_TOO_SHORT;
-
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
@@ -858,6 +855,9 @@
length = (FT_UInt)( valid->limit - table );
}
+ if ( length < 16 )
+ FT_INVALID_TOO_SHORT;
+
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
|
CWE-119
| null | null |
5,654
|
T42_Open_Face( T42_Face face )
{
T42_LoaderRec loader;
T42_Parser parser;
T1_Font type1 = &face->type1;
FT_Memory memory = face->root.memory;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t42_loader_init( &loader, face );
parser = &loader.parser;
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
/* while parsing the font we always update `face->ttf_size' so that */
/* even in case of buggy data (which might lead to premature end of */
/* scanning without causing an error) the call to `FT_Open_Face' in */
/* `T42_Face_Init' passes the correct size */
face->ttf_size = 12;
error = t42_parser_init( parser,
face->root.stream,
memory,
psaux);
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
if ( type1->font_type != 42 )
{
FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
type1->font_type ));
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* now, propagate the charstrings and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* as defined in the CharStrings array. */
/* The index is then stored in type1.encoding.char_index, and */
/* the name in type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t42_loader_done( &loader );
return error;
}
|
DoS
| 0
|
T42_Open_Face( T42_Face face )
{
T42_LoaderRec loader;
T42_Parser parser;
T1_Font type1 = &face->type1;
FT_Memory memory = face->root.memory;
FT_Error error;
PSAux_Service psaux = (PSAux_Service)face->psaux;
t42_loader_init( &loader, face );
parser = &loader.parser;
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
/* while parsing the font we always update `face->ttf_size' so that */
/* even in case of buggy data (which might lead to premature end of */
/* scanning without causing an error) the call to `FT_Open_Face' in */
/* `T42_Face_Init' passes the correct size */
face->ttf_size = 12;
error = t42_parser_init( parser,
face->root.stream,
memory,
psaux);
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( error )
goto Exit;
if ( type1->font_type != 42 )
{
FT_ERROR(( "T42_Open_Face: cannot handle FontType %d\n",
type1->font_type ));
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* now, propagate the charstrings and glyphnames tables */
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face\n" ));
error = FT_THROW( Invalid_File_Format );
}
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
/* we must now build type1.encoding when we have a custom array */
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* glyph_name;
/* OK, we do the following: for each element in the encoding */
/* table, look up the index of the glyph having the same name */
/* as defined in the CharStrings array. */
/* The index is then stored in type1.encoding.char_index, and */
/* the name in type1.encoding.char_name */
min_char = 0;
max_char = 0;
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";
char_name = loader.encoding_table.elements[charcode];
if ( char_name )
for ( idx = 0; idx < type1->num_glyphs; idx++ )
{
glyph_name = (FT_Byte*)type1->glyph_names[idx];
if ( ft_strcmp( (const char*)char_name,
(const char*)glyph_name ) == 0 )
{
type1->encoding.char_index[charcode] = (FT_UShort)idx;
type1->encoding.char_name [charcode] = (char*)glyph_name;
/* Change min/max encoded char only if glyph name is */
/* not /.notdef */
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char )
min_char = charcode;
if ( charcode >= max_char )
max_char = charcode + 1;
}
break;
}
}
}
type1->encoding.code_first = min_char;
type1->encoding.code_last = max_char;
type1->encoding.num_chars = loader.num_chars;
}
Exit:
t42_loader_done( &loader );
return error;
}
|
@@ -292,7 +292,9 @@
FT_Open_Args args;
- args.flags = FT_OPEN_MEMORY;
+ args.flags = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
+ args.driver = FT_Get_Module( FT_FACE_LIBRARY( face ),
+ "truetype" );
args.memory_base = face->ttf_data;
args.memory_size = face->ttf_size;
| null | null | null |
5,655
|
T42_Driver_Done( FT_Module module )
{
FT_UNUSED( module );
}
|
DoS
| 0
|
T42_Driver_Done( FT_Module module )
{
FT_UNUSED( module );
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,656
|
T42_Driver_Init( FT_Module module ) /* T42_Driver */
{
T42_Driver driver = (T42_Driver)module;
FT_Module ttmodule;
ttmodule = FT_Get_Module( module->library, "truetype" );
if ( !ttmodule )
{
FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
return FT_THROW( Missing_Module );
}
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return FT_Err_Ok;
}
|
DoS
| 0
|
T42_Driver_Init( FT_Module module ) /* T42_Driver */
{
T42_Driver driver = (T42_Driver)module;
FT_Module ttmodule;
ttmodule = FT_Get_Module( module->library, "truetype" );
if ( !ttmodule )
{
FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
return FT_THROW( Missing_Module );
}
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return FT_Err_Ok;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,657
|
T42_Face_Done( FT_Face t42face )
{
T42_Face face = (T42_Face)t42face;
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
if ( !face )
return;
type1 = &face->type1;
info = &type1->font_info;
memory = face->root.memory;
/* delete internal ttf face prior to freeing face->ttf_data */
if ( face->ttf_face )
FT_Done_Face( face->ttf_face );
/* release font info strings */
FT_FREE( info->version );
FT_FREE( info->notice );
FT_FREE( info->full_name );
FT_FREE( info->family_name );
FT_FREE( info->weight );
/* release top dictionary */
FT_FREE( type1->charstrings_len );
FT_FREE( type1->charstrings );
FT_FREE( type1->glyph_names );
FT_FREE( type1->charstrings_block );
FT_FREE( type1->glyph_names_block );
FT_FREE( type1->encoding.char_index );
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( face->ttf_data );
#if 0
/* release afm data if present */
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FT_FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = 0;
face->root.style_name = 0;
}
|
DoS
| 0
|
T42_Face_Done( FT_Face t42face )
{
T42_Face face = (T42_Face)t42face;
T1_Font type1;
PS_FontInfo info;
FT_Memory memory;
if ( !face )
return;
type1 = &face->type1;
info = &type1->font_info;
memory = face->root.memory;
/* delete internal ttf face prior to freeing face->ttf_data */
if ( face->ttf_face )
FT_Done_Face( face->ttf_face );
/* release font info strings */
FT_FREE( info->version );
FT_FREE( info->notice );
FT_FREE( info->full_name );
FT_FREE( info->family_name );
FT_FREE( info->weight );
/* release top dictionary */
FT_FREE( type1->charstrings_len );
FT_FREE( type1->charstrings );
FT_FREE( type1->glyph_names );
FT_FREE( type1->charstrings_block );
FT_FREE( type1->glyph_names_block );
FT_FREE( type1->encoding.char_index );
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( face->ttf_data );
#if 0
/* release afm data if present */
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
/* release unicode map, if any */
FT_FREE( face->unicode_map.maps );
face->unicode_map.num_maps = 0;
face->root.family_name = 0;
face->root.style_name = 0;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,658
|
T42_Face_Init( FT_Stream stream,
FT_Face t42face, /* T42_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
T42_Face face = (T42_Face)t42face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( stream );
face->ttf_face = NULL;
face->root.num_faces = 1;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
face->psnames = psnames;
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
if ( !psaux )
{
FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
FT_TRACE2(( "Type 42 driver\n" ));
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
if ( error )
goto Exit;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( face_index > 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Now load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 0;
root->face_index = 0;
root->face_flags |= FT_FACE_FLAG_SCALABLE |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_GLYPH_NAMES;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* We only set this flag if we have the patented bytecode interpreter. */
/* There are no known `tricky' Type42 fonts that could be loaded with */
/* the unpatented interpreter. */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
root->face_flags |= FT_FACE_FLAG_HINTER;
#endif
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = info->family_name;
/* assume "Regular" style if we don't know better */
root->style_name = (char *)"Regular";
if ( root->family_name )
{
char* full = info->full_name;
char* family = root->family_name;
if ( full )
{
while ( *full )
{
if ( *full == *family )
{
family++;
full++;
}
else
{
if ( *full == ' ' || *full == '-' )
full++;
else if ( *family == ' ' || *family == '-' )
family++;
else
{
if ( !*family )
root->style_name = full;
break;
}
}
}
}
}
else
{
/* do we have a `/FontName'? */
if ( type1->font_name )
root->family_name = type1->font_name;
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = 0;
/* Load the TTF font embedded in the T42 font */
{
FT_Open_Args args;
args.flags = FT_OPEN_MEMORY;
args.memory_base = face->ttf_data;
args.memory_size = face->ttf_size;
if ( num_params )
{
args.flags |= FT_OPEN_PARAMS;
args.num_params = num_params;
args.params = params;
}
error = FT_Open_Face( FT_FACE_LIBRARY( face ),
&args, 0, &face->ttf_face );
}
if ( error )
goto Exit;
FT_Done_Size( face->ttf_face->size );
/* Ignore info in FontInfo dictionary and use the info from the */
/* loaded TTF font. The PostScript interpreter also ignores it. */
root->bbox = face->ttf_face->bbox;
root->units_per_EM = face->ttf_face->units_per_EM;
root->ascender = face->ttf_face->ascender;
root->descender = face->ttf_face->descender;
root->height = face->ttf_face->height;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_height = face->ttf_face->max_advance_height;
root->underline_position = (FT_Short)info->underline_position;
root->underline_thickness = (FT_Short)info->underline_thickness;
/* compute style flags */
root->style_flags = 0;
if ( info->italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
root->style_flags |= FT_STYLE_FLAG_BOLD;
if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
FT_CMap_Class clazz;
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
if ( error &&
FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
goto Exit;
error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.encoding_id = TT_ADOBE_ID_STANDARD;
clazz = cmap_classes->standard;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
charmap.encoding_id = TT_ADOBE_ID_EXPERT;
clazz = cmap_classes->expert;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
clazz = cmap_classes->custom;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
clazz = cmap_classes->unicode;
break;
default:
;
}
if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
if ( root->num_charmaps )
root->charmap = root->charmaps[0];
#endif
}
}
Exit:
return error;
}
|
DoS
| 0
|
T42_Face_Init( FT_Stream stream,
FT_Face t42face, /* T42_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
T42_Face face = (T42_Face)t42face;
FT_Error error;
FT_Service_PsCMaps psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( stream );
face->ttf_face = NULL;
face->root.num_faces = 1;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
face->psnames = psnames;
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
if ( !psaux )
{
FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
FT_TRACE2(( "Type 42 driver\n" ));
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
if ( error )
goto Exit;
/* if we just wanted to check the format, leave successfully now */
if ( face_index < 0 )
goto Exit;
/* check the face index */
if ( face_index > 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Now load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 0;
root->face_index = 0;
root->face_flags |= FT_FACE_FLAG_SCALABLE |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_GLYPH_NAMES;
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* We only set this flag if we have the patented bytecode interpreter. */
/* There are no known `tricky' Type42 fonts that could be loaded with */
/* the unpatented interpreter. */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
root->face_flags |= FT_FACE_FLAG_HINTER;
#endif
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = info->family_name;
/* assume "Regular" style if we don't know better */
root->style_name = (char *)"Regular";
if ( root->family_name )
{
char* full = info->full_name;
char* family = root->family_name;
if ( full )
{
while ( *full )
{
if ( *full == *family )
{
family++;
full++;
}
else
{
if ( *full == ' ' || *full == '-' )
full++;
else if ( *family == ' ' || *family == '-' )
family++;
else
{
if ( !*family )
root->style_name = full;
break;
}
}
}
}
}
else
{
/* do we have a `/FontName'? */
if ( type1->font_name )
root->family_name = type1->font_name;
}
/* no embedded bitmap support */
root->num_fixed_sizes = 0;
root->available_sizes = 0;
/* Load the TTF font embedded in the T42 font */
{
FT_Open_Args args;
args.flags = FT_OPEN_MEMORY;
args.memory_base = face->ttf_data;
args.memory_size = face->ttf_size;
if ( num_params )
{
args.flags |= FT_OPEN_PARAMS;
args.num_params = num_params;
args.params = params;
}
error = FT_Open_Face( FT_FACE_LIBRARY( face ),
&args, 0, &face->ttf_face );
}
if ( error )
goto Exit;
FT_Done_Size( face->ttf_face->size );
/* Ignore info in FontInfo dictionary and use the info from the */
/* loaded TTF font. The PostScript interpreter also ignores it. */
root->bbox = face->ttf_face->bbox;
root->units_per_EM = face->ttf_face->units_per_EM;
root->ascender = face->ttf_face->ascender;
root->descender = face->ttf_face->descender;
root->height = face->ttf_face->height;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_height = face->ttf_face->max_advance_height;
root->underline_position = (FT_Short)info->underline_position;
root->underline_thickness = (FT_Short)info->underline_thickness;
/* compute style flags */
root->style_flags = 0;
if ( info->italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
root->style_flags |= FT_STYLE_FLAG_BOLD;
if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
FT_CMap_Class clazz;
charmap.face = root;
/* first of all, try to synthesize a Unicode charmap */
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL );
if ( error &&
FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
goto Exit;
error = FT_Err_Ok;
/* now, generate an Adobe Standard encoding when appropriate */
charmap.platform_id = TT_PLATFORM_ADOBE;
clazz = NULL;
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.encoding_id = TT_ADOBE_ID_STANDARD;
clazz = cmap_classes->standard;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap.encoding = FT_ENCODING_ADOBE_EXPERT;
charmap.encoding_id = TT_ADOBE_ID_EXPERT;
clazz = cmap_classes->expert;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap.encoding = FT_ENCODING_ADOBE_CUSTOM;
charmap.encoding_id = TT_ADOBE_ID_CUSTOM;
clazz = cmap_classes->custom;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap.encoding = FT_ENCODING_ADOBE_LATIN_1;
charmap.encoding_id = TT_ADOBE_ID_LATIN_1;
clazz = cmap_classes->unicode;
break;
default:
;
}
if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
if ( root->num_charmaps )
root->charmap = root->charmaps[0];
#endif
}
}
Exit:
return error;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,659
|
T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Done_GlyphSlot( slot->ttslot );
}
|
DoS
| 0
|
T42_GlyphSlot_Done( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Done_GlyphSlot( slot->ttslot );
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,660
|
T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Face face = t42slot->face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot ttslot;
FT_Error error = FT_Err_Ok;
if ( face->glyph == NULL )
{
/* First glyph slot for this face */
slot->ttslot = t42face->ttf_face->glyph;
}
else
{
error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
slot->ttslot = ttslot;
}
return error;
}
|
DoS
| 0
|
T42_GlyphSlot_Init( FT_GlyphSlot t42slot ) /* T42_GlyphSlot */
{
T42_GlyphSlot slot = (T42_GlyphSlot)t42slot;
FT_Face face = t42slot->face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot ttslot;
FT_Error error = FT_Err_Ok;
if ( face->glyph == NULL )
{
/* First glyph slot for this face */
slot->ttslot = t42face->ttf_face->glyph;
}
else
{
error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot );
slot->ttslot = ttslot;
}
return error;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,661
|
T42_Size_Done( FT_Size t42size ) /* T42_Size */
{
T42_Size size = (T42_Size)t42size;
FT_Face face = t42size->face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
if ( node )
{
FT_Done_Size( size->ttsize );
size->ttsize = NULL;
}
}
|
DoS
| 0
|
T42_Size_Done( FT_Size t42size ) /* T42_Size */
{
T42_Size size = (T42_Size)t42size;
FT_Face face = t42size->face;
T42_Face t42face = (T42_Face)face;
FT_ListNode node;
node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize );
if ( node )
{
FT_Done_Size( size->ttsize );
size->ttsize = NULL;
}
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,662
|
T42_Size_Init( FT_Size size ) /* T42_Size */
{
T42_Size t42size = (T42_Size)size;
FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );
t42size->ttsize = ttsize;
FT_Activate_Size( ttsize );
return error;
}
|
DoS
| 0
|
T42_Size_Init( FT_Size size ) /* T42_Size */
{
T42_Size t42size = (T42_Size)size;
FT_Face face = size->face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error;
error = FT_New_Size( t42face->ttf_face, &ttsize );
t42size->ttsize = ttsize;
FT_Activate_Size( ttsize );
return error;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,663
|
T42_Size_Select( FT_Size t42size, /* T42_Size */
FT_ULong strike_index )
{
T42_Size size = (T42_Size)t42size;
T42_Face face = (T42_Face)t42size->face;
FT_Error error;
FT_Activate_Size( size->ttsize );
error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
if ( !error )
t42size->metrics = face->ttf_face->size->metrics;
return error;
}
|
DoS
| 0
|
T42_Size_Select( FT_Size t42size, /* T42_Size */
FT_ULong strike_index )
{
T42_Size size = (T42_Size)t42size;
T42_Face face = (T42_Face)t42size->face;
FT_Error error;
FT_Activate_Size( size->ttsize );
error = FT_Select_Size( face->ttf_face, (FT_Int)strike_index );
if ( !error )
t42size->metrics = face->ttf_face->size->metrics;
return error;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,664
|
t42_glyphslot_clear( FT_GlyphSlot slot )
{
/* free bitmap if needed */
ft_glyphslot_free_bitmap( slot );
/* clear all public fields in the glyph slot */
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
FT_ZERO( &slot->bitmap );
slot->bitmap_left = 0;
slot->bitmap_top = 0;
slot->num_subglyphs = 0;
slot->subglyphs = 0;
slot->control_data = 0;
slot->control_len = 0;
slot->other = 0;
slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
}
|
DoS
| 0
|
t42_glyphslot_clear( FT_GlyphSlot slot )
{
/* free bitmap if needed */
ft_glyphslot_free_bitmap( slot );
/* clear all public fields in the glyph slot */
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
FT_ZERO( &slot->bitmap );
slot->bitmap_left = 0;
slot->bitmap_top = 0;
slot->num_subglyphs = 0;
slot->subglyphs = 0;
slot->control_data = 0;
slot->control_len = 0;
slot->other = 0;
slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
}
|
@@ -47,6 +47,12 @@
if ( FT_ALLOC( face->ttf_data, 12 ) )
goto Exit;
+ /* while parsing the font we always update `face->ttf_size' so that */
+ /* even in case of buggy data (which might lead to premature end of */
+ /* scanning without causing an error) the call to `FT_Open_Face' in */
+ /* `T42_Face_Init' passes the correct size */
+ face->ttf_size = 12;
+
error = t42_parser_init( parser,
face->root.stream,
memory,
| null | null | null |
5,665
|
_bdf_add_property( bdf_font_t* font,
char* name,
char* value,
unsigned long lineno )
{
size_t propid;
hashnode hn;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno ); /* only used in debug mode */
/* First, check whether the property already exists in the font. */
if ( ( hn = hash_lookup( name, (hashtable *)font->internal ) ) != 0 )
{
/* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */
fp = font->props + hn->data;
switch ( fp->format )
{
case BDF_ATOM:
/* Delete the current atom if it exists. */
FT_FREE( fp->value.atom );
if ( value && value[0] != 0 )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
default:
;
}
goto Exit;
}
/* See whether this property type exists yet or not. */
/* If not, create it. */
hn = hash_lookup( name, &(font->proptbl) );
if ( hn == 0 )
{
error = bdf_create_property( name, BDF_ATOM, font );
if ( error )
goto Exit;
hn = hash_lookup( name, &(font->proptbl) );
}
/* Allocate another property if this is overflow. */
if ( font->props_used == font->props_size )
{
if ( font->props_size == 0 )
{
if ( FT_NEW_ARRAY( font->props, 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->props,
font->props_size,
font->props_size + 1 ) )
goto Exit;
}
fp = font->props + font->props_size;
FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
font->props_size++;
}
propid = hn->data;
if ( propid >= _num_bdf_properties )
prop = font->user_props + ( propid - _num_bdf_properties );
else
prop = (bdf_property_t*)_bdf_properties + propid;
fp = font->props + font->props_used;
fp->name = prop->name;
fp->format = prop->format;
fp->builtin = prop->builtin;
switch ( prop->format )
{
case BDF_ATOM:
fp->value.atom = 0;
if ( value != 0 && value[0] )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
}
/* If the property happens to be a comment, then it doesn't need */
/* to be added to the internal hash table. */
if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
{
/* Add the property to the font property table. */
error = hash_insert( fp->name,
font->props_used,
(hashtable *)font->internal,
memory );
if ( error )
goto Exit;
}
font->props_used++;
/* Some special cases need to be handled here. The DEFAULT_CHAR */
/* property needs to be located if it exists in the property list, the */
/* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
/* present, and the SPACING property should override the default */
/* spacing. */
if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.l;
else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
{
FT_ERROR(( "_bdf_add_property: " ERRMSG8, lineno, "SPACING" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( fp->value.atom[0] == 'p' || fp->value.atom[0] == 'P' )
font->spacing = BDF_PROPORTIONAL;
else if ( fp->value.atom[0] == 'm' || fp->value.atom[0] == 'M' )
font->spacing = BDF_MONOWIDTH;
else if ( fp->value.atom[0] == 'c' || fp->value.atom[0] == 'C' )
font->spacing = BDF_CHARCELL;
}
Exit:
return error;
}
|
DoS
| 0
|
_bdf_add_property( bdf_font_t* font,
char* name,
char* value,
unsigned long lineno )
{
size_t propid;
hashnode hn;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = FT_Err_Ok;
FT_UNUSED( lineno ); /* only used in debug mode */
/* First, check whether the property already exists in the font. */
if ( ( hn = hash_lookup( name, (hashtable *)font->internal ) ) != 0 )
{
/* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */
fp = font->props + hn->data;
switch ( fp->format )
{
case BDF_ATOM:
/* Delete the current atom if it exists. */
FT_FREE( fp->value.atom );
if ( value && value[0] != 0 )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
default:
;
}
goto Exit;
}
/* See whether this property type exists yet or not. */
/* If not, create it. */
hn = hash_lookup( name, &(font->proptbl) );
if ( hn == 0 )
{
error = bdf_create_property( name, BDF_ATOM, font );
if ( error )
goto Exit;
hn = hash_lookup( name, &(font->proptbl) );
}
/* Allocate another property if this is overflow. */
if ( font->props_used == font->props_size )
{
if ( font->props_size == 0 )
{
if ( FT_NEW_ARRAY( font->props, 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->props,
font->props_size,
font->props_size + 1 ) )
goto Exit;
}
fp = font->props + font->props_size;
FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
font->props_size++;
}
propid = hn->data;
if ( propid >= _num_bdf_properties )
prop = font->user_props + ( propid - _num_bdf_properties );
else
prop = (bdf_property_t*)_bdf_properties + propid;
fp = font->props + font->props_used;
fp->name = prop->name;
fp->format = prop->format;
fp->builtin = prop->builtin;
switch ( prop->format )
{
case BDF_ATOM:
fp->value.atom = 0;
if ( value != 0 && value[0] )
{
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
}
break;
case BDF_INTEGER:
fp->value.l = _bdf_atol( value, 0, 10 );
break;
case BDF_CARDINAL:
fp->value.ul = _bdf_atoul( value, 0, 10 );
break;
}
/* If the property happens to be a comment, then it doesn't need */
/* to be added to the internal hash table. */
if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
{
/* Add the property to the font property table. */
error = hash_insert( fp->name,
font->props_used,
(hashtable *)font->internal,
memory );
if ( error )
goto Exit;
}
font->props_used++;
/* Some special cases need to be handled here. The DEFAULT_CHAR */
/* property needs to be located if it exists in the property list, the */
/* FONT_ASCENT and FONT_DESCENT need to be assigned if they are */
/* present, and the SPACING property should override the default */
/* spacing. */
if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_char = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.l;
else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
font->font_descent = fp->value.l;
else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
{
if ( !fp->value.atom )
{
FT_ERROR(( "_bdf_add_property: " ERRMSG8, lineno, "SPACING" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( fp->value.atom[0] == 'p' || fp->value.atom[0] == 'P' )
font->spacing = BDF_PROPORTIONAL;
else if ( fp->value.atom[0] == 'm' || fp->value.atom[0] == 'M' )
font->spacing = BDF_MONOWIDTH;
else if ( fp->value.atom[0] == 'c' || fp->value.atom[0] == 'C' )
font->spacing = BDF_CHARCELL;
}
Exit:
return error;
}
|
@@ -1555,6 +1555,14 @@
/* Check for the ENDFONT field. */
if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
+ if ( p->flags & _BDF_GLYPH_BITS )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
+ }
+
/* Sort the glyphs by encoding. */
ft_qsort( (char *)font->glyphs,
font->glyphs_used,
|
CWE-476
| null | null |
5,666
|
_bdf_list_ensure( _bdf_list_t* list,
unsigned long num_items ) /* same as _bdf_list_t.used */
{
FT_Error error = FT_Err_Ok;
if ( num_items > list->size )
{
unsigned long oldsize = list->size; /* same as _bdf_list_t.size */
unsigned long newsize = oldsize + ( oldsize >> 1 ) + 5;
unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
FT_Memory memory = list->memory;
if ( oldsize == bigsize )
{
error = FT_THROW( Out_Of_Memory );
goto Exit;
}
else if ( newsize < oldsize || newsize > bigsize )
newsize = bigsize;
if ( FT_RENEW_ARRAY( list->field, oldsize, newsize ) )
goto Exit;
list->size = newsize;
}
Exit:
return error;
}
|
DoS
| 0
|
_bdf_list_ensure( _bdf_list_t* list,
unsigned long num_items ) /* same as _bdf_list_t.used */
{
FT_Error error = FT_Err_Ok;
if ( num_items > list->size )
{
unsigned long oldsize = list->size; /* same as _bdf_list_t.size */
unsigned long newsize = oldsize + ( oldsize >> 1 ) + 5;
unsigned long bigsize = (unsigned long)( FT_INT_MAX / sizeof ( char* ) );
FT_Memory memory = list->memory;
if ( oldsize == bigsize )
{
error = FT_THROW( Out_Of_Memory );
goto Exit;
}
else if ( newsize < oldsize || newsize > bigsize )
newsize = bigsize;
if ( FT_RENEW_ARRAY( list->field, oldsize, newsize ) )
goto Exit;
list->size = newsize;
}
Exit:
return error;
}
|
@@ -1555,6 +1555,14 @@
/* Check for the ENDFONT field. */
if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
+ if ( p->flags & _BDF_GLYPH_BITS )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
+ }
+
/* Sort the glyphs by encoding. */
ft_qsort( (char *)font->glyphs,
font->glyphs_used,
|
CWE-476
| null | null |
5,667
|
_bdf_list_join( _bdf_list_t* list,
int c,
unsigned long *alen )
{
unsigned long i, j;
char* dp;
*alen = 0;
if ( list == 0 || list->used == 0 )
return 0;
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
char* fp = list->field[i];
while ( *fp )
dp[j++] = *fp++;
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
if ( dp != empty )
dp[j] = 0;
*alen = j;
return dp;
}
|
DoS
| 0
|
_bdf_list_join( _bdf_list_t* list,
int c,
unsigned long *alen )
{
unsigned long i, j;
char* dp;
*alen = 0;
if ( list == 0 || list->used == 0 )
return 0;
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
char* fp = list->field[i];
while ( *fp )
dp[j++] = *fp++;
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
if ( dp != empty )
dp[j] = 0;
*alen = j;
return dp;
}
|
@@ -1555,6 +1555,14 @@
/* Check for the ENDFONT field. */
if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
+ if ( p->flags & _BDF_GLYPH_BITS )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
+ }
+
/* Sort the glyphs by encoding. */
ft_qsort( (char *)font->glyphs,
font->glyphs_used,
|
CWE-476
| null | null |
5,668
|
_bdf_list_split( _bdf_list_t* list,
char* separators,
char* line,
unsigned long linelen )
{
int mult, final_empty;
char *sp, *ep, *end;
char seps[32];
FT_Error error = FT_Err_Ok;
/* Initialize the list. */
list->used = 0;
if ( list->size )
{
list->field[0] = (char*)empty;
list->field[1] = (char*)empty;
list->field[2] = (char*)empty;
list->field[3] = (char*)empty;
list->field[4] = (char*)empty;
}
/* If the line is empty, then simply return. */
if ( linelen == 0 || line[0] == 0 )
goto Exit;
/* In the original code, if the `separators' parameter is NULL or */
/* empty, the list is split into individual bytes. We don't need */
/* this, so an error is signaled. */
if ( separators == 0 || *separators == 0 )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Prepare the separator bitmap. */
FT_MEM_ZERO( seps, 32 );
/* If the very last character of the separator string is a plus, then */
/* set the `mult' flag to indicate that multiple separators should be */
/* collapsed into one. */
for ( mult = 0, sp = separators; sp && *sp; sp++ )
{
if ( *sp == '+' && *( sp + 1 ) == 0 )
mult = 1;
else
setsbit( seps, *sp );
}
/* Break the line up into fields. */
for ( final_empty = 0, sp = ep = line, end = sp + linelen;
sp < end && *sp; )
{
/* Collect everything that is not a separator. */
for ( ; *ep && !sbitset( seps, *ep ); ep++ )
;
/* Resize the list if necessary. */
if ( list->used == list->size )
{
error = _bdf_list_ensure( list, list->used + 1 );
if ( error )
goto Exit;
}
/* Assign the field appropriately. */
list->field[list->used++] = ( ep > sp ) ? sp : (char*)empty;
sp = ep;
if ( mult )
{
/* If multiple separators should be collapsed, do it now by */
/* setting all the separator characters to 0. */
for ( ; *ep && sbitset( seps, *ep ); ep++ )
*ep = 0;
}
else if ( *ep != 0 )
/* Don't collapse multiple separators by making them 0, so just */
/* make the one encountered 0. */
*ep++ = 0;
final_empty = ( ep > sp && *ep == 0 );
sp = ep;
}
/* Finally, NULL-terminate the list. */
if ( list->used + final_empty >= list->size )
{
error = _bdf_list_ensure( list, list->used + final_empty + 1 );
if ( error )
goto Exit;
}
if ( final_empty )
list->field[list->used++] = (char*)empty;
list->field[list->used] = 0;
Exit:
return error;
}
|
DoS
| 0
|
_bdf_list_split( _bdf_list_t* list,
char* separators,
char* line,
unsigned long linelen )
{
int mult, final_empty;
char *sp, *ep, *end;
char seps[32];
FT_Error error = FT_Err_Ok;
/* Initialize the list. */
list->used = 0;
if ( list->size )
{
list->field[0] = (char*)empty;
list->field[1] = (char*)empty;
list->field[2] = (char*)empty;
list->field[3] = (char*)empty;
list->field[4] = (char*)empty;
}
/* If the line is empty, then simply return. */
if ( linelen == 0 || line[0] == 0 )
goto Exit;
/* In the original code, if the `separators' parameter is NULL or */
/* empty, the list is split into individual bytes. We don't need */
/* this, so an error is signaled. */
if ( separators == 0 || *separators == 0 )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Prepare the separator bitmap. */
FT_MEM_ZERO( seps, 32 );
/* If the very last character of the separator string is a plus, then */
/* set the `mult' flag to indicate that multiple separators should be */
/* collapsed into one. */
for ( mult = 0, sp = separators; sp && *sp; sp++ )
{
if ( *sp == '+' && *( sp + 1 ) == 0 )
mult = 1;
else
setsbit( seps, *sp );
}
/* Break the line up into fields. */
for ( final_empty = 0, sp = ep = line, end = sp + linelen;
sp < end && *sp; )
{
/* Collect everything that is not a separator. */
for ( ; *ep && !sbitset( seps, *ep ); ep++ )
;
/* Resize the list if necessary. */
if ( list->used == list->size )
{
error = _bdf_list_ensure( list, list->used + 1 );
if ( error )
goto Exit;
}
/* Assign the field appropriately. */
list->field[list->used++] = ( ep > sp ) ? sp : (char*)empty;
sp = ep;
if ( mult )
{
/* If multiple separators should be collapsed, do it now by */
/* setting all the separator characters to 0. */
for ( ; *ep && sbitset( seps, *ep ); ep++ )
*ep = 0;
}
else if ( *ep != 0 )
/* Don't collapse multiple separators by making them 0, so just */
/* make the one encountered 0. */
*ep++ = 0;
final_empty = ( ep > sp && *ep == 0 );
sp = ep;
}
/* Finally, NULL-terminate the list. */
if ( list->used + final_empty >= list->size )
{
error = _bdf_list_ensure( list, list->used + final_empty + 1 );
if ( error )
goto Exit;
}
if ( final_empty )
list->field[list->used++] = (char*)empty;
list->field[list->used] = 0;
Exit:
return error;
}
|
@@ -1555,6 +1555,14 @@
/* Check for the ENDFONT field. */
if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
+ if ( p->flags & _BDF_GLYPH_BITS )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Corrupted_Font_Glyphs );
+ goto Exit;
+ }
+
/* Sort the glyphs by encoding. */
ft_qsort( (char *)font->glyphs,
font->glyphs_used,
|
CWE-476
| null | null |
5,669
|
cf2_getWindingMomentum( CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2 )
{
/* cross product of pt1 position from origin with pt2 position from */
/* pt1; we reduce the precision so that the result fits into 32 bits */
return ( x1 >> 16 ) * ( ( y2 - y1 ) >> 16 ) -
( y1 >> 16 ) * ( ( x2 - x1 ) >> 16 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_getWindingMomentum( CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2 )
{
/* cross product of pt1 position from origin with pt2 position from */
/* pt1; we reduce the precision so that the result fits into 32 bits */
return ( x1 >> 16 ) * ( ( y2 - y1 ) >> 16 ) -
( y1 >> 16 ) * ( ( x2 - x1 ) >> 16 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,670
|
cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath )
{
if ( glyphpath->pathIsOpen )
{
/*
* A closing line in Character Space line is always generated below
* with `cf2_glyphPath_lineTo'. It may be ignored later if it turns
* out to be zero length in Device Space.
*/
glyphpath->pathIsClosing = TRUE;
cf2_glyphpath_lineTo( glyphpath,
glyphpath->start.x,
glyphpath->start.y );
/* empty the final element from the queue and close the path */
if ( glyphpath->elemIsQueued )
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&glyphpath->offsetStart0,
glyphpath->offsetStart1,
TRUE );
/* reset state machine */
glyphpath->moveIsPending = TRUE;
glyphpath->pathIsOpen = FALSE;
glyphpath->pathIsClosing = FALSE;
glyphpath->elemIsQueued = FALSE;
}
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath )
{
if ( glyphpath->pathIsOpen )
{
/*
* A closing line in Character Space line is always generated below
* with `cf2_glyphPath_lineTo'. It may be ignored later if it turns
* out to be zero length in Device Space.
*/
glyphpath->pathIsClosing = TRUE;
cf2_glyphpath_lineTo( glyphpath,
glyphpath->start.x,
glyphpath->start.y );
/* empty the final element from the queue and close the path */
if ( glyphpath->elemIsQueued )
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&glyphpath->offsetStart0,
glyphpath->offsetStart1,
TRUE );
/* reset state machine */
glyphpath->moveIsPending = TRUE;
glyphpath->pathIsOpen = FALSE;
glyphpath->pathIsClosing = FALSE;
glyphpath->elemIsQueued = FALSE;
}
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,671
|
cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath,
CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2,
CF2_Fixed* x,
CF2_Fixed* y )
{
CF2_Fixed dx = x2 - x1;
CF2_Fixed dy = y2 - y1;
/* note: negative offsets don't work here; negate deltas to change */
/* quadrants, below */
if ( glyphpath->font->reverseWinding )
{
dx = -dx;
dy = -dy;
}
*x = *y = 0;
if ( !glyphpath->darken )
return;
/* add momentum for this path element */
glyphpath->callbacks->windingMomentum +=
cf2_getWindingMomentum( x1, y1, x2, y2 );
/* note: allow mixed integer and fixed multiplication here */
if ( dx >= 0 )
{
if ( dy >= 0 )
{
/* first quadrant, +x +y */
if ( dx > 2 * dy )
{
/* +x */
*x = 0;
*y = 0;
}
else if ( dy > 2 * dx )
{
/* +y */
*x = glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* +x +y */
*x = FT_MulFix( cf2_floatToFixed( 0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
glyphpath->yOffset );
}
}
else
{
/* fourth quadrant, +x -y */
if ( dx > -2 * dy )
{
/* +x */
*x = 0;
*y = 0;
}
else if ( -dy > 2 * dx )
{
/* -y */
*x = -glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* +x -y */
*x = FT_MulFix( cf2_floatToFixed( -0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
glyphpath->yOffset );
}
}
}
else
{
if ( dy >= 0 )
{
/* second quadrant, -x +y */
if ( -dx > 2 * dy )
{
/* -x */
*x = 0;
*y = 2 * glyphpath->yOffset;
}
else if ( dy > -2 * dx )
{
/* +y */
*x = glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* -x +y */
*x = FT_MulFix( cf2_floatToFixed( 0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ),
glyphpath->yOffset );
}
}
else
{
/* third quadrant, -x -y */
if ( -dx > -2 * dy )
{
/* -x */
*x = 0;
*y = 2 * glyphpath->yOffset;
}
else if ( -dy > -2 * dx )
{
/* -y */
*x = -glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* -x -y */
*x = FT_MulFix( cf2_floatToFixed( -0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ),
glyphpath->yOffset );
}
}
}
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath,
CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2,
CF2_Fixed* x,
CF2_Fixed* y )
{
CF2_Fixed dx = x2 - x1;
CF2_Fixed dy = y2 - y1;
/* note: negative offsets don't work here; negate deltas to change */
/* quadrants, below */
if ( glyphpath->font->reverseWinding )
{
dx = -dx;
dy = -dy;
}
*x = *y = 0;
if ( !glyphpath->darken )
return;
/* add momentum for this path element */
glyphpath->callbacks->windingMomentum +=
cf2_getWindingMomentum( x1, y1, x2, y2 );
/* note: allow mixed integer and fixed multiplication here */
if ( dx >= 0 )
{
if ( dy >= 0 )
{
/* first quadrant, +x +y */
if ( dx > 2 * dy )
{
/* +x */
*x = 0;
*y = 0;
}
else if ( dy > 2 * dx )
{
/* +y */
*x = glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* +x +y */
*x = FT_MulFix( cf2_floatToFixed( 0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
glyphpath->yOffset );
}
}
else
{
/* fourth quadrant, +x -y */
if ( dx > -2 * dy )
{
/* +x */
*x = 0;
*y = 0;
}
else if ( -dy > 2 * dx )
{
/* -y */
*x = -glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* +x -y */
*x = FT_MulFix( cf2_floatToFixed( -0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ),
glyphpath->yOffset );
}
}
}
else
{
if ( dy >= 0 )
{
/* second quadrant, -x +y */
if ( -dx > 2 * dy )
{
/* -x */
*x = 0;
*y = 2 * glyphpath->yOffset;
}
else if ( dy > -2 * dx )
{
/* +y */
*x = glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* -x +y */
*x = FT_MulFix( cf2_floatToFixed( 0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ),
glyphpath->yOffset );
}
}
else
{
/* third quadrant, -x -y */
if ( -dx > -2 * dy )
{
/* -x */
*x = 0;
*y = 2 * glyphpath->yOffset;
}
else if ( -dy > -2 * dx )
{
/* -y */
*x = -glyphpath->xOffset;
*y = glyphpath->yOffset;
}
else
{
/* -x -y */
*x = FT_MulFix( cf2_floatToFixed( -0.7 ),
glyphpath->xOffset );
*y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ),
glyphpath->yOffset );
}
}
}
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,672
|
cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2,
CF2_Fixed x3,
CF2_Fixed y3 )
{
CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3;
FT_Vector P0, P1, P2, P3;
/* TODO: ignore zero length portions of curve?? */
cf2_glyphpath_computeOffset( glyphpath,
glyphpath->currentCS.x,
glyphpath->currentCS.y,
x1,
y1,
&xOffset1,
&yOffset1 );
cf2_glyphpath_computeOffset( glyphpath,
x2,
y2,
x3,
y3,
&xOffset3,
&yOffset3 );
/* add momentum from the middle segment */
glyphpath->callbacks->windingMomentum +=
cf2_getWindingMomentum( x1, y1, x2, y2 );
/* construct offset points */
P0.x = glyphpath->currentCS.x + xOffset1;
P0.y = glyphpath->currentCS.y + yOffset1;
P1.x = x1 + xOffset1;
P1.y = y1 + yOffset1;
/* note: preserve angle of final segment by using offset3 at both ends */
P2.x = x2 + xOffset3;
P2.y = y2 + yOffset3;
P3.x = x3 + xOffset3;
P3.y = y3 + yOffset3;
if ( glyphpath->moveIsPending )
{
/* emit offset 1st point as MoveTo */
cf2_glyphpath_pushMove( glyphpath, P0 );
glyphpath->moveIsPending = FALSE;
glyphpath->pathIsOpen = TRUE;
glyphpath->offsetStart1 = P1; /* record second point */
}
if ( glyphpath->elemIsQueued )
{
FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&P0,
P1,
FALSE );
}
/* queue the current element with offset points */
glyphpath->elemIsQueued = TRUE;
glyphpath->prevElemOp = CF2_PathOpCubeTo;
glyphpath->prevElemP0 = P0;
glyphpath->prevElemP1 = P1;
glyphpath->prevElemP2 = P2;
glyphpath->prevElemP3 = P3;
/* update current map */
if ( cf2_hintmask_isNew( glyphpath->hintMask ) )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
glyphpath->currentCS.x = x3; /* pre-offset current point */
glyphpath->currentCS.y = y3;
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
CF2_Fixed x1,
CF2_Fixed y1,
CF2_Fixed x2,
CF2_Fixed y2,
CF2_Fixed x3,
CF2_Fixed y3 )
{
CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3;
FT_Vector P0, P1, P2, P3;
/* TODO: ignore zero length portions of curve?? */
cf2_glyphpath_computeOffset( glyphpath,
glyphpath->currentCS.x,
glyphpath->currentCS.y,
x1,
y1,
&xOffset1,
&yOffset1 );
cf2_glyphpath_computeOffset( glyphpath,
x2,
y2,
x3,
y3,
&xOffset3,
&yOffset3 );
/* add momentum from the middle segment */
glyphpath->callbacks->windingMomentum +=
cf2_getWindingMomentum( x1, y1, x2, y2 );
/* construct offset points */
P0.x = glyphpath->currentCS.x + xOffset1;
P0.y = glyphpath->currentCS.y + yOffset1;
P1.x = x1 + xOffset1;
P1.y = y1 + yOffset1;
/* note: preserve angle of final segment by using offset3 at both ends */
P2.x = x2 + xOffset3;
P2.y = y2 + yOffset3;
P3.x = x3 + xOffset3;
P3.y = y3 + yOffset3;
if ( glyphpath->moveIsPending )
{
/* emit offset 1st point as MoveTo */
cf2_glyphpath_pushMove( glyphpath, P0 );
glyphpath->moveIsPending = FALSE;
glyphpath->pathIsOpen = TRUE;
glyphpath->offsetStart1 = P1; /* record second point */
}
if ( glyphpath->elemIsQueued )
{
FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&P0,
P1,
FALSE );
}
/* queue the current element with offset points */
glyphpath->elemIsQueued = TRUE;
glyphpath->prevElemOp = CF2_PathOpCubeTo;
glyphpath->prevElemP0 = P0;
glyphpath->prevElemP1 = P1;
glyphpath->prevElemP2 = P2;
glyphpath->prevElemP3 = P3;
/* update current map */
if ( cf2_hintmask_isNew( glyphpath->hintMask ) )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
glyphpath->currentCS.x = x3; /* pre-offset current point */
glyphpath->currentCS.y = y3;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,673
|
cf2_glyphpath_finalize( CF2_GlyphPath glyphpath )
{
cf2_arrstack_finalize( &glyphpath->hintMoves );
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_finalize( CF2_GlyphPath glyphpath )
{
cf2_arrstack_finalize( &glyphpath->hintMoves );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,674
|
cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath,
CF2_HintMap hintmap,
FT_Vector* ppt,
CF2_Fixed x,
CF2_Fixed y )
{
FT_Vector pt; /* hinted point in upright DS */
pt.x = FT_MulFix( glyphpath->scaleX, x ) +
FT_MulFix( glyphpath->scaleC, y );
pt.y = cf2_hintmap_map( hintmap, y );
ppt->x = FT_MulFix( glyphpath->font->outerTransform.a, pt.x ) +
FT_MulFix( glyphpath->font->outerTransform.c, pt.y ) +
glyphpath->fractionalTranslation.x;
ppt->y = FT_MulFix( glyphpath->font->outerTransform.b, pt.x ) +
FT_MulFix( glyphpath->font->outerTransform.d, pt.y ) +
glyphpath->fractionalTranslation.y;
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath,
CF2_HintMap hintmap,
FT_Vector* ppt,
CF2_Fixed x,
CF2_Fixed y )
{
FT_Vector pt; /* hinted point in upright DS */
pt.x = FT_MulFix( glyphpath->scaleX, x ) +
FT_MulFix( glyphpath->scaleC, y );
pt.y = cf2_hintmap_map( hintmap, y );
ppt->x = FT_MulFix( glyphpath->font->outerTransform.a, pt.x ) +
FT_MulFix( glyphpath->font->outerTransform.c, pt.y ) +
glyphpath->fractionalTranslation.x;
ppt->y = FT_MulFix( glyphpath->font->outerTransform.b, pt.x ) +
FT_MulFix( glyphpath->font->outerTransform.d, pt.y ) +
glyphpath->fractionalTranslation.y;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,675
|
cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
CF2_Fixed x,
CF2_Fixed y )
{
CF2_Fixed xOffset, yOffset;
FT_Vector P0, P1;
FT_Bool newHintMap;
/*
* New hints will be applied after cf2_glyphpath_pushPrevElem has run.
* In case this is a synthesized closing line, any new hints should be
* delayed until this path is closed (`cf2_hintmask_isNew' will be
* called again before the next line or curve).
*/
/* true if new hint map not on close */
newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) &&
!glyphpath->pathIsClosing;
/*
* Zero-length lines may occur in the charstring. Because we cannot
* compute darkening offsets or intersections from zero-length lines,
* it is best to remove them and avoid artifacts. However, zero-length
* lines in CS at the start of a new hint map can generate non-zero
* lines in DS due to hint substitution. We detect a change in hint
* map here and pass those zero-length lines along.
*/
/*
* Note: Find explicitly closed paths here with a conditional
* breakpoint using
*
* !gp->pathIsClosing && gp->start.x == x && gp->start.y == y
*
*/
if ( glyphpath->currentCS.x == x &&
glyphpath->currentCS.y == y &&
!newHintMap )
/*
* Ignore zero-length lines in CS where the hint map is the same
* because the line in DS will also be zero length.
*
* Ignore zero-length lines when we synthesize a closing line because
* the close will be handled in cf2_glyphPath_pushPrevElem.
*/
return;
cf2_glyphpath_computeOffset( glyphpath,
glyphpath->currentCS.x,
glyphpath->currentCS.y,
x,
y,
&xOffset,
&yOffset );
/* construct offset points */
P0.x = glyphpath->currentCS.x + xOffset;
P0.y = glyphpath->currentCS.y + yOffset;
P1.x = x + xOffset;
P1.y = y + yOffset;
if ( glyphpath->moveIsPending )
{
/* emit offset 1st point as MoveTo */
cf2_glyphpath_pushMove( glyphpath, P0 );
glyphpath->moveIsPending = FALSE; /* adjust state machine */
glyphpath->pathIsOpen = TRUE;
glyphpath->offsetStart1 = P1; /* record second point */
}
if ( glyphpath->elemIsQueued )
{
FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&P0,
P1,
FALSE );
}
/* queue the current element with offset points */
glyphpath->elemIsQueued = TRUE;
glyphpath->prevElemOp = CF2_PathOpLineTo;
glyphpath->prevElemP0 = P0;
glyphpath->prevElemP1 = P1;
/* update current map */
if ( newHintMap )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
glyphpath->currentCS.x = x; /* pre-offset current point */
glyphpath->currentCS.y = y;
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
CF2_Fixed x,
CF2_Fixed y )
{
CF2_Fixed xOffset, yOffset;
FT_Vector P0, P1;
FT_Bool newHintMap;
/*
* New hints will be applied after cf2_glyphpath_pushPrevElem has run.
* In case this is a synthesized closing line, any new hints should be
* delayed until this path is closed (`cf2_hintmask_isNew' will be
* called again before the next line or curve).
*/
/* true if new hint map not on close */
newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) &&
!glyphpath->pathIsClosing;
/*
* Zero-length lines may occur in the charstring. Because we cannot
* compute darkening offsets or intersections from zero-length lines,
* it is best to remove them and avoid artifacts. However, zero-length
* lines in CS at the start of a new hint map can generate non-zero
* lines in DS due to hint substitution. We detect a change in hint
* map here and pass those zero-length lines along.
*/
/*
* Note: Find explicitly closed paths here with a conditional
* breakpoint using
*
* !gp->pathIsClosing && gp->start.x == x && gp->start.y == y
*
*/
if ( glyphpath->currentCS.x == x &&
glyphpath->currentCS.y == y &&
!newHintMap )
/*
* Ignore zero-length lines in CS where the hint map is the same
* because the line in DS will also be zero length.
*
* Ignore zero-length lines when we synthesize a closing line because
* the close will be handled in cf2_glyphPath_pushPrevElem.
*/
return;
cf2_glyphpath_computeOffset( glyphpath,
glyphpath->currentCS.x,
glyphpath->currentCS.y,
x,
y,
&xOffset,
&yOffset );
/* construct offset points */
P0.x = glyphpath->currentCS.x + xOffset;
P0.y = glyphpath->currentCS.y + yOffset;
P1.x = x + xOffset;
P1.y = y + yOffset;
if ( glyphpath->moveIsPending )
{
/* emit offset 1st point as MoveTo */
cf2_glyphpath_pushMove( glyphpath, P0 );
glyphpath->moveIsPending = FALSE; /* adjust state machine */
glyphpath->pathIsOpen = TRUE;
glyphpath->offsetStart1 = P1; /* record second point */
}
if ( glyphpath->elemIsQueued )
{
FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
cf2_glyphpath_pushPrevElem( glyphpath,
&glyphpath->hintMap,
&P0,
P1,
FALSE );
}
/* queue the current element with offset points */
glyphpath->elemIsQueued = TRUE;
glyphpath->prevElemOp = CF2_PathOpLineTo;
glyphpath->prevElemP0 = P0;
glyphpath->prevElemP1 = P1;
/* update current map */
if ( newHintMap )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
glyphpath->currentCS.x = x; /* pre-offset current point */
glyphpath->currentCS.y = y;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,676
|
cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
CF2_Fixed x,
CF2_Fixed y )
{
cf2_glyphpath_closeOpenPath( glyphpath );
/* save the parameters of the move for later, when we'll know how to */
/* offset it; */
/* also save last move point */
glyphpath->currentCS.x = glyphpath->start.x = x;
glyphpath->currentCS.y = glyphpath->start.y = y;
glyphpath->moveIsPending = TRUE;
/* ensure we have a valid map with current mask */
if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ||
cf2_hintmask_isNew( glyphpath->hintMask ) )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
/* save a copy of current HintMap to use when drawing initial point */
glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
CF2_Fixed x,
CF2_Fixed y )
{
cf2_glyphpath_closeOpenPath( glyphpath );
/* save the parameters of the move for later, when we'll know how to */
/* offset it; */
/* also save last move point */
glyphpath->currentCS.x = glyphpath->start.x = x;
glyphpath->currentCS.y = glyphpath->start.y = y;
glyphpath->moveIsPending = TRUE;
/* ensure we have a valid map with current mask */
if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ||
cf2_hintmask_isNew( glyphpath->hintMask ) )
cf2_hintmap_build( &glyphpath->hintMap,
glyphpath->hStemHintArray,
glyphpath->vStemHintArray,
glyphpath->hintMask,
glyphpath->hintOriginY,
FALSE );
/* save a copy of current HintMap to use when drawing initial point */
glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,677
|
cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath,
FT_Vector start )
{
CF2_CallbackParamsRec params;
params.op = CF2_PathOpMoveTo;
params.pt0 = glyphpath->currentDS;
/* Test if move has really happened yet; it would have called */
/* `cf2_hintmap_build' to set `isValid'. */
if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) )
{
/* we are here iff first subpath is missing a moveto operator: */
/* synthesize first moveTo to finish initialization of hintMap */
cf2_glyphpath_moveTo( glyphpath,
glyphpath->start.x,
glyphpath->start.y );
}
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->hintMap,
¶ms.pt1,
start.x,
start.y );
/* note: pt2 and pt3 are unused */
glyphpath->callbacks->moveTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
glyphpath->offsetStart0 = start;
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath,
FT_Vector start )
{
CF2_CallbackParamsRec params;
params.op = CF2_PathOpMoveTo;
params.pt0 = glyphpath->currentDS;
/* Test if move has really happened yet; it would have called */
/* `cf2_hintmap_build' to set `isValid'. */
if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) )
{
/* we are here iff first subpath is missing a moveto operator: */
/* synthesize first moveTo to finish initialization of hintMap */
cf2_glyphpath_moveTo( glyphpath,
glyphpath->start.x,
glyphpath->start.y );
}
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->hintMap,
¶ms.pt1,
start.x,
start.y );
/* note: pt2 and pt3 are unused */
glyphpath->callbacks->moveTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
glyphpath->offsetStart0 = start;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,678
|
cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath,
CF2_HintMap hintmap,
FT_Vector* nextP0,
FT_Vector nextP1,
FT_Bool close )
{
CF2_CallbackParamsRec params;
FT_Vector* prevP0;
FT_Vector* prevP1;
FT_Vector intersection = { 0, 0 };
FT_Bool useIntersection = FALSE;
FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo ||
glyphpath->prevElemOp == CF2_PathOpCubeTo );
if ( glyphpath->prevElemOp == CF2_PathOpLineTo )
{
prevP0 = &glyphpath->prevElemP0;
prevP1 = &glyphpath->prevElemP1;
}
else
{
prevP0 = &glyphpath->prevElemP2;
prevP1 = &glyphpath->prevElemP3;
}
/* optimization: if previous and next elements are offset by the same */
/* amount, then there will be no gap, and no need to compute an */
/* intersection. */
if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y )
{
/* previous element does not join next element: */
/* adjust end point of previous element to the intersection */
useIntersection = cf2_glyphpath_computeIntersection( glyphpath,
prevP0,
prevP1,
nextP0,
&nextP1,
&intersection );
if ( useIntersection )
{
/* modify the last point of the cached element (either line or */
/* curve) */
*prevP1 = intersection;
}
}
params.pt0 = glyphpath->currentDS;
switch( glyphpath->prevElemOp )
{
case CF2_PathOpLineTo:
params.op = CF2_PathOpLineTo;
/* note: pt2 and pt3 are unused */
if ( close )
{
/* use first hint map if closing */
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->firstHintMap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
}
else
{
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
}
/* output only non-zero length lines */
if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y )
{
glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
}
break;
case CF2_PathOpCubeTo:
params.op = CF2_PathOpCubeTo;
/* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt2,
glyphpath->prevElemP2.x,
glyphpath->prevElemP2.y );
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt3,
glyphpath->prevElemP3.x,
glyphpath->prevElemP3.y );
glyphpath->callbacks->cubeTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt3;
break;
}
if ( !useIntersection || close )
{
/* insert connecting line between end of previous element and start */
/* of current one */
/* note: at the end of a subpath, we might do both, so use `nextP0' */
/* before we change it, below */
if ( close )
{
/* if we are closing the subpath, then nextP0 is in the first */
/* hint zone */
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->firstHintMap,
¶ms.pt1,
nextP0->x,
nextP0->y );
}
else
{
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
nextP0->x,
nextP0->y );
}
if ( params.pt1.x != glyphpath->currentDS.x ||
params.pt1.y != glyphpath->currentDS.y )
{
/* length is nonzero */
params.op = CF2_PathOpLineTo;
params.pt0 = glyphpath->currentDS;
/* note: pt2 and pt3 are unused */
glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
}
}
if ( useIntersection )
{
/* return intersection point to caller */
*nextP0 = intersection;
}
}
|
DoS Exec Code Overflow
| 0
|
cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath,
CF2_HintMap hintmap,
FT_Vector* nextP0,
FT_Vector nextP1,
FT_Bool close )
{
CF2_CallbackParamsRec params;
FT_Vector* prevP0;
FT_Vector* prevP1;
FT_Vector intersection = { 0, 0 };
FT_Bool useIntersection = FALSE;
FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo ||
glyphpath->prevElemOp == CF2_PathOpCubeTo );
if ( glyphpath->prevElemOp == CF2_PathOpLineTo )
{
prevP0 = &glyphpath->prevElemP0;
prevP1 = &glyphpath->prevElemP1;
}
else
{
prevP0 = &glyphpath->prevElemP2;
prevP1 = &glyphpath->prevElemP3;
}
/* optimization: if previous and next elements are offset by the same */
/* amount, then there will be no gap, and no need to compute an */
/* intersection. */
if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y )
{
/* previous element does not join next element: */
/* adjust end point of previous element to the intersection */
useIntersection = cf2_glyphpath_computeIntersection( glyphpath,
prevP0,
prevP1,
nextP0,
&nextP1,
&intersection );
if ( useIntersection )
{
/* modify the last point of the cached element (either line or */
/* curve) */
*prevP1 = intersection;
}
}
params.pt0 = glyphpath->currentDS;
switch( glyphpath->prevElemOp )
{
case CF2_PathOpLineTo:
params.op = CF2_PathOpLineTo;
/* note: pt2 and pt3 are unused */
if ( close )
{
/* use first hint map if closing */
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->firstHintMap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
}
else
{
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
}
/* output only non-zero length lines */
if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y )
{
glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
}
break;
case CF2_PathOpCubeTo:
params.op = CF2_PathOpCubeTo;
/* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
glyphpath->prevElemP1.x,
glyphpath->prevElemP1.y );
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt2,
glyphpath->prevElemP2.x,
glyphpath->prevElemP2.y );
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt3,
glyphpath->prevElemP3.x,
glyphpath->prevElemP3.y );
glyphpath->callbacks->cubeTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt3;
break;
}
if ( !useIntersection || close )
{
/* insert connecting line between end of previous element and start */
/* of current one */
/* note: at the end of a subpath, we might do both, so use `nextP0' */
/* before we change it, below */
if ( close )
{
/* if we are closing the subpath, then nextP0 is in the first */
/* hint zone */
cf2_glyphpath_hintPoint( glyphpath,
&glyphpath->firstHintMap,
¶ms.pt1,
nextP0->x,
nextP0->y );
}
else
{
cf2_glyphpath_hintPoint( glyphpath,
hintmap,
¶ms.pt1,
nextP0->x,
nextP0->y );
}
if ( params.pt1.x != glyphpath->currentDS.x ||
params.pt1.y != glyphpath->currentDS.y )
{
/* length is nonzero */
params.op = CF2_PathOpLineTo;
params.pt0 = glyphpath->currentDS;
/* note: pt2 and pt3 are unused */
glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms );
glyphpath->currentDS = params.pt1;
}
}
if ( useIntersection )
{
/* return intersection point to caller */
*nextP0 = intersection;
}
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,679
|
cf2_hint_isBottom( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags &
( CF2_PairBottom | CF2_GhostBottom ) ) != 0 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_isBottom( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags &
( CF2_PairBottom | CF2_GhostBottom ) ) != 0 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,680
|
cf2_hint_isLocked( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_isLocked( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,681
|
cf2_hint_isPair( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags &
( CF2_PairBottom | CF2_PairTop ) ) != 0 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_isPair( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags &
( CF2_PairBottom | CF2_PairTop ) ) != 0 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,682
|
cf2_hint_isPairTop( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_isPairTop( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,683
|
cf2_hint_isSynthetic( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 );
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_isSynthetic( const CF2_Hint hint )
{
return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 );
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,684
|
cf2_hint_lock( CF2_Hint hint )
{
hint->flags |= CF2_Locked;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hint_lock( CF2_Hint hint )
{
hint->flags |= CF2_Locked;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,685
|
cf2_hintmap_adjustHints( CF2_HintMap hintmap )
{
size_t i, j;
cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */
/*
* First pass is bottom-up (font hint order) without look-ahead.
* Locked edges are already adjusted.
* Unlocked edges begin with dsCoord from `initialHintMap'.
* Save edges that are not optimally adjusted in `hintMoves' array,
* and process them in second pass.
*/
for ( i = 0; i < hintmap->count; i++ )
{
FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] );
/* index of upper edge (same value for ghost hint) */
j = isPair ? i + 1 : i;
FT_ASSERT( j < hintmap->count );
FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) );
FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) );
FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) ==
cf2_hint_isLocked( &hintmap->edge[j] ) );
if ( !cf2_hint_isLocked( &hintmap->edge[i] ) )
{
/* hint edge is not locked, we can adjust it */
CF2_Fixed fracDown = cf2_fixedFraction( hintmap->edge[i].dsCoord );
CF2_Fixed fracUp = cf2_fixedFraction( hintmap->edge[j].dsCoord );
/* calculate all four possibilities; moves down are negative */
CF2_Fixed downMoveDown = 0 - fracDown;
CF2_Fixed upMoveDown = 0 - fracUp;
CF2_Fixed downMoveUp = fracDown == 0
? 0
: cf2_intToFixed( 1 ) - fracDown;
CF2_Fixed upMoveUp = fracUp == 0
? 0
: cf2_intToFixed( 1 ) - fracUp;
/* smallest move up */
CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp );
/* smallest move down */
CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown );
/* final amount to move edge or edge pair */
CF2_Fixed move;
CF2_Fixed downMinCounter = CF2_MIN_COUNTER;
CF2_Fixed upMinCounter = CF2_MIN_COUNTER;
FT_Bool saveEdge = FALSE;
/* minimum counter constraint doesn't apply when adjacent edges */
/* are synthetic */
/* TODO: doesn't seem a big effect; for now, reduce the code */
#if 0
if ( i == 0 ||
cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) )
downMinCounter = 0;
if ( j >= hintmap->count - 1 ||
cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) )
upMinCounter = 0;
#endif
/* is there room to move up? */
/* there is if we are at top of array or the next edge is at or */
/* beyond proposed move up? */
if ( j >= hintmap->count - 1 ||
hintmap->edge[j + 1].dsCoord >=
hintmap->edge[j].dsCoord + moveUp + upMinCounter )
{
/* there is room to move up; is there also room to move down? */
if ( i == 0 ||
hintmap->edge[i - 1].dsCoord <=
hintmap->edge[i].dsCoord + moveDown - downMinCounter )
{
/* move smaller absolute amount */
move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */
}
else
move = moveUp;
}
else
{
/* is there room to move down? */
if ( i == 0 ||
hintmap->edge[i - 1].dsCoord <=
hintmap->edge[i].dsCoord + moveDown - downMinCounter )
{
move = moveDown;
/* true if non-optimum move */
saveEdge = (FT_Bool)( moveUp < -moveDown );
}
else
{
/* no room to move either way without overlapping or reducing */
/* the counter too much */
move = 0;
saveEdge = TRUE;
}
}
/* Identify non-moves and moves down that aren't optimal, and save */
/* them for second pass. */
/* Do this only if there is an unlocked edge above (which could */
/* possibly move). */
if ( saveEdge &&
j < hintmap->count - 1 &&
!cf2_hint_isLocked( &hintmap->edge[j + 1] ) )
{
CF2_HintMoveRec savedMove;
savedMove.j = j;
/* desired adjustment in second pass */
savedMove.moveUp = moveUp - move;
cf2_arrstack_push( hintmap->hintMoves, &savedMove );
}
/* move the edge(s) */
hintmap->edge[i].dsCoord += move;
if ( isPair )
hintmap->edge[j].dsCoord += move;
}
/* assert there are no overlaps in device space */
FT_ASSERT( i == 0 ||
hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord );
FT_ASSERT( i < j ||
hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord );
/* adjust the scales, avoiding divide by zero */
if ( i > 0 )
{
if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord )
hintmap->edge[i - 1].scale =
FT_DivFix(
hintmap->edge[i].dsCoord - hintmap->edge[i - 1].dsCoord,
hintmap->edge[i].csCoord - hintmap->edge[i - 1].csCoord );
}
if ( isPair )
{
if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord )
hintmap->edge[j - 1].scale =
FT_DivFix(
hintmap->edge[j].dsCoord - hintmap->edge[j - 1].dsCoord,
hintmap->edge[j].csCoord - hintmap->edge[j - 1].csCoord );
i += 1; /* skip upper edge on next loop */
}
}
/* second pass tries to move non-optimal hints up, in case there is */
/* room now */
for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- )
{
CF2_HintMove hintMove = (CF2_HintMove)
cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 );
j = hintMove->j;
/* this was tested before the push, above */
FT_ASSERT( j < hintmap->count - 1 );
/* is there room to move up? */
if ( hintmap->edge[j + 1].dsCoord >=
hintmap->edge[j].dsCoord + hintMove->moveUp + CF2_MIN_COUNTER )
{
/* there is more room now, move edge up */
hintmap->edge[j].dsCoord += hintMove->moveUp;
if ( cf2_hint_isPair( &hintmap->edge[j] ) )
{
FT_ASSERT( j > 0 );
hintmap->edge[j - 1].dsCoord += hintMove->moveUp;
}
}
}
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmap_adjustHints( CF2_HintMap hintmap )
{
size_t i, j;
cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */
/*
* First pass is bottom-up (font hint order) without look-ahead.
* Locked edges are already adjusted.
* Unlocked edges begin with dsCoord from `initialHintMap'.
* Save edges that are not optimally adjusted in `hintMoves' array,
* and process them in second pass.
*/
for ( i = 0; i < hintmap->count; i++ )
{
FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] );
/* index of upper edge (same value for ghost hint) */
j = isPair ? i + 1 : i;
FT_ASSERT( j < hintmap->count );
FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) );
FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) );
FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) ==
cf2_hint_isLocked( &hintmap->edge[j] ) );
if ( !cf2_hint_isLocked( &hintmap->edge[i] ) )
{
/* hint edge is not locked, we can adjust it */
CF2_Fixed fracDown = cf2_fixedFraction( hintmap->edge[i].dsCoord );
CF2_Fixed fracUp = cf2_fixedFraction( hintmap->edge[j].dsCoord );
/* calculate all four possibilities; moves down are negative */
CF2_Fixed downMoveDown = 0 - fracDown;
CF2_Fixed upMoveDown = 0 - fracUp;
CF2_Fixed downMoveUp = fracDown == 0
? 0
: cf2_intToFixed( 1 ) - fracDown;
CF2_Fixed upMoveUp = fracUp == 0
? 0
: cf2_intToFixed( 1 ) - fracUp;
/* smallest move up */
CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp );
/* smallest move down */
CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown );
/* final amount to move edge or edge pair */
CF2_Fixed move;
CF2_Fixed downMinCounter = CF2_MIN_COUNTER;
CF2_Fixed upMinCounter = CF2_MIN_COUNTER;
FT_Bool saveEdge = FALSE;
/* minimum counter constraint doesn't apply when adjacent edges */
/* are synthetic */
/* TODO: doesn't seem a big effect; for now, reduce the code */
#if 0
if ( i == 0 ||
cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) )
downMinCounter = 0;
if ( j >= hintmap->count - 1 ||
cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) )
upMinCounter = 0;
#endif
/* is there room to move up? */
/* there is if we are at top of array or the next edge is at or */
/* beyond proposed move up? */
if ( j >= hintmap->count - 1 ||
hintmap->edge[j + 1].dsCoord >=
hintmap->edge[j].dsCoord + moveUp + upMinCounter )
{
/* there is room to move up; is there also room to move down? */
if ( i == 0 ||
hintmap->edge[i - 1].dsCoord <=
hintmap->edge[i].dsCoord + moveDown - downMinCounter )
{
/* move smaller absolute amount */
move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */
}
else
move = moveUp;
}
else
{
/* is there room to move down? */
if ( i == 0 ||
hintmap->edge[i - 1].dsCoord <=
hintmap->edge[i].dsCoord + moveDown - downMinCounter )
{
move = moveDown;
/* true if non-optimum move */
saveEdge = (FT_Bool)( moveUp < -moveDown );
}
else
{
/* no room to move either way without overlapping or reducing */
/* the counter too much */
move = 0;
saveEdge = TRUE;
}
}
/* Identify non-moves and moves down that aren't optimal, and save */
/* them for second pass. */
/* Do this only if there is an unlocked edge above (which could */
/* possibly move). */
if ( saveEdge &&
j < hintmap->count - 1 &&
!cf2_hint_isLocked( &hintmap->edge[j + 1] ) )
{
CF2_HintMoveRec savedMove;
savedMove.j = j;
/* desired adjustment in second pass */
savedMove.moveUp = moveUp - move;
cf2_arrstack_push( hintmap->hintMoves, &savedMove );
}
/* move the edge(s) */
hintmap->edge[i].dsCoord += move;
if ( isPair )
hintmap->edge[j].dsCoord += move;
}
/* assert there are no overlaps in device space */
FT_ASSERT( i == 0 ||
hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord );
FT_ASSERT( i < j ||
hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord );
/* adjust the scales, avoiding divide by zero */
if ( i > 0 )
{
if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord )
hintmap->edge[i - 1].scale =
FT_DivFix(
hintmap->edge[i].dsCoord - hintmap->edge[i - 1].dsCoord,
hintmap->edge[i].csCoord - hintmap->edge[i - 1].csCoord );
}
if ( isPair )
{
if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord )
hintmap->edge[j - 1].scale =
FT_DivFix(
hintmap->edge[j].dsCoord - hintmap->edge[j - 1].dsCoord,
hintmap->edge[j].csCoord - hintmap->edge[j - 1].csCoord );
i += 1; /* skip upper edge on next loop */
}
}
/* second pass tries to move non-optimal hints up, in case there is */
/* room now */
for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- )
{
CF2_HintMove hintMove = (CF2_HintMove)
cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 );
j = hintMove->j;
/* this was tested before the push, above */
FT_ASSERT( j < hintmap->count - 1 );
/* is there room to move up? */
if ( hintmap->edge[j + 1].dsCoord >=
hintmap->edge[j].dsCoord + hintMove->moveUp + CF2_MIN_COUNTER )
{
/* there is more room now, move edge up */
hintmap->edge[j].dsCoord += hintMove->moveUp;
if ( cf2_hint_isPair( &hintmap->edge[j] ) )
{
FT_ASSERT( j > 0 );
hintmap->edge[j - 1].dsCoord += hintMove->moveUp;
}
}
}
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,686
|
cf2_hintmap_init( CF2_HintMap hintmap,
CF2_Font font,
CF2_HintMap initialMap,
CF2_ArrStack hintMoves,
CF2_Fixed scale )
{
FT_ZERO( hintmap );
/* copy parameters from font instance */
hintmap->hinted = font->hinted;
hintmap->scale = scale;
hintmap->font = font;
hintmap->initialHintMap = initialMap;
/* will clear in `cf2_hintmap_adjustHints' */
hintmap->hintMoves = hintMoves;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmap_init( CF2_HintMap hintmap,
CF2_Font font,
CF2_HintMap initialMap,
CF2_ArrStack hintMoves,
CF2_Fixed scale )
{
FT_ZERO( hintmap );
/* copy parameters from font instance */
hintmap->hinted = font->hinted;
hintmap->scale = scale;
hintmap->font = font;
hintmap->initialHintMap = initialMap;
/* will clear in `cf2_hintmap_adjustHints' */
hintmap->hintMoves = hintMoves;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,687
|
cf2_hintmap_insertHint( CF2_HintMap hintmap,
CF2_Hint bottomHintEdge,
CF2_Hint topHintEdge )
{
CF2_UInt indexInsert;
/* set default values, then check for edge hints */
FT_Bool isPair = TRUE;
CF2_Hint firstHintEdge = bottomHintEdge;
CF2_Hint secondHintEdge = topHintEdge;
/* one or none of the input params may be invalid when dealing with */
/* edge hints; at least one edge must be valid */
FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) ||
cf2_hint_isValid( topHintEdge ) );
/* determine how many and which edges to insert */
if ( !cf2_hint_isValid( bottomHintEdge ) )
{
/* insert only the top edge */
firstHintEdge = topHintEdge;
isPair = FALSE;
}
else if ( !cf2_hint_isValid( topHintEdge ) )
{
/* insert only the bottom edge */
isPair = FALSE;
}
/* paired edges must be in proper order */
FT_ASSERT( !isPair ||
topHintEdge->csCoord >= bottomHintEdge->csCoord );
/* linear search to find index value of insertion point */
indexInsert = 0;
for ( ; indexInsert < hintmap->count; indexInsert++ )
{
if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord )
break;
}
/*
* Discard any hints that overlap in character space. Most often, this
* is while building the initial map, where captured hints from all
* zones are combined. Define overlap to include hints that `touch'
* (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that
* touch. Some fonts have non-ideographic glyphs that overlap our
* synthetic hints.
*
* Overlap also occurs when darkening stem hints that are close.
*
*/
if ( indexInsert < hintmap->count )
{
/* we are inserting before an existing edge: */
/* verify that an existing edge is not the same */
if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord )
return; /* ignore overlapping stem hint */
/* verify that a new pair does not straddle the next edge */
if ( isPair &&
hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord )
return; /* ignore overlapping stem hint */
/* verify that we are not inserting between paired edges */
if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) )
return; /* ignore overlapping stem hint */
}
/* recompute device space locations using initial hint map */
if ( cf2_hintmap_isValid( hintmap->initialHintMap ) &&
!cf2_hint_isLocked( firstHintEdge ) )
{
if ( isPair )
{
/* Use hint map to position the center of stem, and nominal scale */
/* to position the two edges. This preserves the stem width. */
CF2_Fixed midpoint = cf2_hintmap_map(
hintmap->initialHintMap,
( secondHintEdge->csCoord +
firstHintEdge->csCoord ) / 2 );
CF2_Fixed halfWidth = FT_MulFix(
( secondHintEdge->csCoord -
firstHintEdge->csCoord ) / 2,
hintmap->scale );
firstHintEdge->dsCoord = midpoint - halfWidth;
secondHintEdge->dsCoord = midpoint + halfWidth;
}
else
firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap,
firstHintEdge->csCoord );
}
/*
* Discard any hints that overlap in device space; this can occur
* because locked hints have been moved to align with blue zones.
*
* TODO: Although we might correct this later during adjustment, we
* don't currently have a way to delete a conflicting hint once it has
* been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened,
* initial hint map for second path, glyph 945 (the perispomeni (tilde)
* in U+1F6E, Greek omega with psili and perispomeni). Darkening is
* 25. Pair 667,747 initially conflicts in design space with top edge
* 660. This is because 667 maps to 7.87, and the top edge was
* captured by a zone at 8.0. The pair is later successfully inserted
* in a zone without the top edge. In this zone it is adjusted to 8.0,
* and no longer conflicts with the top edge in design space. This
* means it can be included in yet a later zone which does have the top
* edge hint. This produces a small mismatch between the first and
* last points of this path, even though the hint masks are the same.
* The density map difference is tiny (1/256).
*
*/
if ( indexInsert > 0 )
{
/* we are inserting after an existing edge */
if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord )
return;
}
if ( indexInsert < hintmap->count )
{
/* we are inserting before an existing edge */
if ( isPair )
{
if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
return;
}
else
{
if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
return;
}
}
/* make room to insert */
{
CF2_Int iSrc = hintmap->count - 1;
CF2_Int iDst = isPair ? hintmap->count + 1 : hintmap->count;
CF2_Int count = hintmap->count - indexInsert;
if ( iDst >= CF2_MAX_HINT_EDGES )
{
FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" ));
return;
}
while ( count-- )
hintmap->edge[iDst--] = hintmap->edge[iSrc--];
/* insert first edge */
hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */
hintmap->count += 1;
if ( isPair )
{
/* insert second edge */
hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
hintmap->count += 1;
}
}
return;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmap_insertHint( CF2_HintMap hintmap,
CF2_Hint bottomHintEdge,
CF2_Hint topHintEdge )
{
CF2_UInt indexInsert;
/* set default values, then check for edge hints */
FT_Bool isPair = TRUE;
CF2_Hint firstHintEdge = bottomHintEdge;
CF2_Hint secondHintEdge = topHintEdge;
/* one or none of the input params may be invalid when dealing with */
/* edge hints; at least one edge must be valid */
FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) ||
cf2_hint_isValid( topHintEdge ) );
/* determine how many and which edges to insert */
if ( !cf2_hint_isValid( bottomHintEdge ) )
{
/* insert only the top edge */
firstHintEdge = topHintEdge;
isPair = FALSE;
}
else if ( !cf2_hint_isValid( topHintEdge ) )
{
/* insert only the bottom edge */
isPair = FALSE;
}
/* paired edges must be in proper order */
FT_ASSERT( !isPair ||
topHintEdge->csCoord >= bottomHintEdge->csCoord );
/* linear search to find index value of insertion point */
indexInsert = 0;
for ( ; indexInsert < hintmap->count; indexInsert++ )
{
if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord )
break;
}
/*
* Discard any hints that overlap in character space. Most often, this
* is while building the initial map, where captured hints from all
* zones are combined. Define overlap to include hints that `touch'
* (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that
* touch. Some fonts have non-ideographic glyphs that overlap our
* synthetic hints.
*
* Overlap also occurs when darkening stem hints that are close.
*
*/
if ( indexInsert < hintmap->count )
{
/* we are inserting before an existing edge: */
/* verify that an existing edge is not the same */
if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord )
return; /* ignore overlapping stem hint */
/* verify that a new pair does not straddle the next edge */
if ( isPair &&
hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord )
return; /* ignore overlapping stem hint */
/* verify that we are not inserting between paired edges */
if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) )
return; /* ignore overlapping stem hint */
}
/* recompute device space locations using initial hint map */
if ( cf2_hintmap_isValid( hintmap->initialHintMap ) &&
!cf2_hint_isLocked( firstHintEdge ) )
{
if ( isPair )
{
/* Use hint map to position the center of stem, and nominal scale */
/* to position the two edges. This preserves the stem width. */
CF2_Fixed midpoint = cf2_hintmap_map(
hintmap->initialHintMap,
( secondHintEdge->csCoord +
firstHintEdge->csCoord ) / 2 );
CF2_Fixed halfWidth = FT_MulFix(
( secondHintEdge->csCoord -
firstHintEdge->csCoord ) / 2,
hintmap->scale );
firstHintEdge->dsCoord = midpoint - halfWidth;
secondHintEdge->dsCoord = midpoint + halfWidth;
}
else
firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap,
firstHintEdge->csCoord );
}
/*
* Discard any hints that overlap in device space; this can occur
* because locked hints have been moved to align with blue zones.
*
* TODO: Although we might correct this later during adjustment, we
* don't currently have a way to delete a conflicting hint once it has
* been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened,
* initial hint map for second path, glyph 945 (the perispomeni (tilde)
* in U+1F6E, Greek omega with psili and perispomeni). Darkening is
* 25. Pair 667,747 initially conflicts in design space with top edge
* 660. This is because 667 maps to 7.87, and the top edge was
* captured by a zone at 8.0. The pair is later successfully inserted
* in a zone without the top edge. In this zone it is adjusted to 8.0,
* and no longer conflicts with the top edge in design space. This
* means it can be included in yet a later zone which does have the top
* edge hint. This produces a small mismatch between the first and
* last points of this path, even though the hint masks are the same.
* The density map difference is tiny (1/256).
*
*/
if ( indexInsert > 0 )
{
/* we are inserting after an existing edge */
if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord )
return;
}
if ( indexInsert < hintmap->count )
{
/* we are inserting before an existing edge */
if ( isPair )
{
if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
return;
}
else
{
if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
return;
}
}
/* make room to insert */
{
CF2_Int iSrc = hintmap->count - 1;
CF2_Int iDst = isPair ? hintmap->count + 1 : hintmap->count;
CF2_Int count = hintmap->count - indexInsert;
if ( iDst >= CF2_MAX_HINT_EDGES )
{
FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" ));
return;
}
while ( count-- )
hintmap->edge[iDst--] = hintmap->edge[iSrc--];
/* insert first edge */
hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */
hintmap->count += 1;
if ( isPair )
{
/* insert second edge */
hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
hintmap->count += 1;
}
}
return;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,688
|
cf2_hintmap_isValid( const CF2_HintMap hintmap )
{
return hintmap->isValid;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmap_isValid( const CF2_HintMap hintmap )
{
return hintmap->isValid;
}
|
@@ -794,9 +794,12 @@
maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
/* use the hStem hints only, which are first in the mask */
- /* TODO: compare this to cffhintmaskGetBitCount */
bitCount = cf2_arrstack_size( hStemHintArray );
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
/* synthetic embox hints get highest priority */
if ( font->blues.doEmBoxHints )
{
|
CWE-119
| null | null |
5,689
|
cf2_doFlex( CF2_Stack opStack,
CF2_Fixed* curX,
CF2_Fixed* curY,
CF2_GlyphPath glyphPath,
const FT_Bool* readFromStack,
FT_Bool doConditionalLastRead )
{
CF2_Fixed vals[14];
CF2_UInt index;
FT_Bool isHFlex;
CF2_Int top, i, j;
vals[0] = *curX;
vals[1] = *curY;
index = 0;
isHFlex = readFromStack[9] == FALSE;
top = isHFlex ? 9 : 10;
for ( i = 0; i < top; i++ )
{
vals[i + 2] = vals[i];
if ( readFromStack[i] )
vals[i + 2] += cf2_stack_getReal( opStack, index++ );
}
if ( isHFlex )
vals[9 + 2] = *curY;
if ( doConditionalLastRead )
{
FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) >
cf2_fixedAbs( vals[11] - *curY ) );
CF2_Fixed lastVal = cf2_stack_getReal( opStack, index );
if ( lastIsX )
{
vals[12] = vals[10] + lastVal;
vals[13] = *curY;
}
else
{
vals[12] = *curX;
vals[13] = vals[11] + lastVal;
}
}
else
{
if ( readFromStack[10] )
vals[12] = vals[10] + cf2_stack_getReal( opStack, index++ );
else
vals[12] = *curX;
if ( readFromStack[11] )
vals[13] = vals[11] + cf2_stack_getReal( opStack, index );
else
vals[13] = *curY;
}
for ( j = 0; j < 2; j++ )
cf2_glyphpath_curveTo( glyphPath, vals[j * 6 + 2],
vals[j * 6 + 3],
vals[j * 6 + 4],
vals[j * 6 + 5],
vals[j * 6 + 6],
vals[j * 6 + 7] );
cf2_stack_clear( opStack );
*curX = vals[12];
*curY = vals[13];
}
|
DoS Exec Code Overflow
| 0
|
cf2_doFlex( CF2_Stack opStack,
CF2_Fixed* curX,
CF2_Fixed* curY,
CF2_GlyphPath glyphPath,
const FT_Bool* readFromStack,
FT_Bool doConditionalLastRead )
{
CF2_Fixed vals[14];
CF2_UInt index;
FT_Bool isHFlex;
CF2_Int top, i, j;
vals[0] = *curX;
vals[1] = *curY;
index = 0;
isHFlex = readFromStack[9] == FALSE;
top = isHFlex ? 9 : 10;
for ( i = 0; i < top; i++ )
{
vals[i + 2] = vals[i];
if ( readFromStack[i] )
vals[i + 2] += cf2_stack_getReal( opStack, index++ );
}
if ( isHFlex )
vals[9 + 2] = *curY;
if ( doConditionalLastRead )
{
FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) >
cf2_fixedAbs( vals[11] - *curY ) );
CF2_Fixed lastVal = cf2_stack_getReal( opStack, index );
if ( lastIsX )
{
vals[12] = vals[10] + lastVal;
vals[13] = *curY;
}
else
{
vals[12] = *curX;
vals[13] = vals[11] + lastVal;
}
}
else
{
if ( readFromStack[10] )
vals[12] = vals[10] + cf2_stack_getReal( opStack, index++ );
else
vals[12] = *curX;
if ( readFromStack[11] )
vals[13] = vals[11] + cf2_stack_getReal( opStack, index );
else
vals[13] = *curY;
}
for ( j = 0; j < 2; j++ )
cf2_glyphpath_curveTo( glyphPath, vals[j * 6 + 2],
vals[j * 6 + 3],
vals[j * 6 + 4],
vals[j * 6 + 5],
vals[j * 6 + 6],
vals[j * 6 + 7] );
cf2_stack_clear( opStack );
*curX = vals[12];
*curY = vals[13];
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,690
|
cf2_hintmask_getMaskPtr( CF2_HintMask hintmask )
{
return hintmask->mask;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_getMaskPtr( CF2_HintMask hintmask )
{
return hintmask->mask;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,691
|
cf2_hintmask_init( CF2_HintMask hintmask,
FT_Error* error )
{
FT_ZERO( hintmask );
hintmask->error = error;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_init( CF2_HintMask hintmask,
FT_Error* error )
{
FT_ZERO( hintmask );
hintmask->error = error;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,692
|
cf2_hintmask_isNew( const CF2_HintMask hintmask )
{
return hintmask->isNew;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_isNew( const CF2_HintMask hintmask )
{
return hintmask->isNew;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,693
|
cf2_hintmask_isValid( const CF2_HintMask hintmask )
{
return hintmask->isValid;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_isValid( const CF2_HintMask hintmask )
{
return hintmask->isValid;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,694
|
cf2_hintmask_read( CF2_HintMask hintmask,
CF2_Buffer charstring,
size_t bitCount )
{
size_t i;
#ifndef CF2_NDEBUG
/* these are the bits in the final mask byte that should be zero */
/* Note: this variable is only used in an assert expression below */
/* and then only if CF2_NDEBUG is not defined */
CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
#endif
/* initialize counts and isValid */
if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
return;
FT_ASSERT( hintmask->byteCount > 0 );
FT_TRACE4(( " (maskbytes:" ));
/* set mask and advance interpreter's charstring pointer */
for ( i = 0; i < hintmask->byteCount; i++ )
{
hintmask->mask[i] = (FT_Byte)cf2_buf_readByte( charstring );
FT_TRACE4(( " 0x%02X", hintmask->mask[i] ));
}
FT_TRACE4(( ")\n" ));
/* assert any unused bits in last byte are zero unless there's a prior */
/* error */
/* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
#ifndef CF2_NDEBUG
FT_ASSERT( ( hintmask->mask[hintmask->byteCount - 1] & mask ) == 0 ||
*hintmask->error );
#endif
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_read( CF2_HintMask hintmask,
CF2_Buffer charstring,
size_t bitCount )
{
size_t i;
#ifndef CF2_NDEBUG
/* these are the bits in the final mask byte that should be zero */
/* Note: this variable is only used in an assert expression below */
/* and then only if CF2_NDEBUG is not defined */
CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
#endif
/* initialize counts and isValid */
if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
return;
FT_ASSERT( hintmask->byteCount > 0 );
FT_TRACE4(( " (maskbytes:" ));
/* set mask and advance interpreter's charstring pointer */
for ( i = 0; i < hintmask->byteCount; i++ )
{
hintmask->mask[i] = (FT_Byte)cf2_buf_readByte( charstring );
FT_TRACE4(( " 0x%02X", hintmask->mask[i] ));
}
FT_TRACE4(( ")\n" ));
/* assert any unused bits in last byte are zero unless there's a prior */
/* error */
/* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
#ifndef CF2_NDEBUG
FT_ASSERT( ( hintmask->mask[hintmask->byteCount - 1] & mask ) == 0 ||
*hintmask->error );
#endif
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,695
|
cf2_hintmask_setAll( CF2_HintMask hintmask,
size_t bitCount )
{
size_t i;
CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
/* initialize counts and isValid */
if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
return;
FT_ASSERT( hintmask->byteCount > 0 );
FT_ASSERT( hintmask->byteCount <
sizeof ( hintmask->mask ) / sizeof ( hintmask->mask[0] ) );
/* set mask to all ones */
for ( i = 0; i < hintmask->byteCount; i++ )
hintmask->mask[i] = 0xFF;
/* clear unused bits */
/* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
hintmask->mask[hintmask->byteCount - 1] &= ~mask;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_setAll( CF2_HintMask hintmask,
size_t bitCount )
{
size_t i;
CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
/* initialize counts and isValid */
if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
return;
FT_ASSERT( hintmask->byteCount > 0 );
FT_ASSERT( hintmask->byteCount <
sizeof ( hintmask->mask ) / sizeof ( hintmask->mask[0] ) );
/* set mask to all ones */
for ( i = 0; i < hintmask->byteCount; i++ )
hintmask->mask[i] = 0xFF;
/* clear unused bits */
/* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
hintmask->mask[hintmask->byteCount - 1] &= ~mask;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,696
|
cf2_hintmask_setCounts( CF2_HintMask hintmask,
size_t bitCount )
{
if ( bitCount > CF2_MAX_HINTS )
{
/* total of h and v stems must be <= 96 */
CF2_SET_ERROR( hintmask->error, Invalid_Glyph_Format );
return 0;
}
hintmask->bitCount = bitCount;
hintmask->byteCount = ( hintmask->bitCount + 7 ) / 8;
hintmask->isValid = TRUE;
hintmask->isNew = TRUE;
return bitCount;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_setCounts( CF2_HintMask hintmask,
size_t bitCount )
{
if ( bitCount > CF2_MAX_HINTS )
{
/* total of h and v stems must be <= 96 */
CF2_SET_ERROR( hintmask->error, Invalid_Glyph_Format );
return 0;
}
hintmask->bitCount = bitCount;
hintmask->byteCount = ( hintmask->bitCount + 7 ) / 8;
hintmask->isValid = TRUE;
hintmask->isNew = TRUE;
return bitCount;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,697
|
cf2_hintmask_setNew( CF2_HintMask hintmask,
FT_Bool val )
{
hintmask->isNew = val;
}
|
DoS Exec Code Overflow
| 0
|
cf2_hintmask_setNew( CF2_HintMask hintmask,
FT_Bool val )
{
hintmask->isNew = val;
}
|
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -593,8 +593,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +617,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -1141,15 +1147,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
|
CWE-119
| null | null |
5,698
|
tt_face_done_kern( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->kern_table );
face->kern_table_size = 0;
face->num_kern_tables = 0;
face->kern_avail_bits = 0;
face->kern_order_bits = 0;
}
|
DoS
| 0
|
tt_face_done_kern( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->kern_table );
face->kern_table_size = 0;
face->num_kern_tables = 0;
face->kern_avail_bits = 0;
face->kern_order_bits = 0;
}
|
@@ -99,7 +99,7 @@
length = FT_NEXT_USHORT( p );
coverage = FT_NEXT_USHORT( p );
- if ( length <= 6 )
+ if ( length <= 6 + 8 )
break;
p_next += length;
|
CWE-125
| null | null |
5,699
|
tt_face_done_loca( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->glyph_locations );
face->num_locations = 0;
}
|
DoS
| 0
|
tt_face_done_loca( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->glyph_locations );
face->num_locations = 0;
}
|
@@ -508,9 +508,9 @@
record_size = FT_NEXT_ULONG( p );
/* The maximum number of bytes in an hdmx device record is the */
- /* maximum number of glyphs + 2; this is 0xFFFF + 2; this is */
- /* the reason why `record_size' is a long (which we read as */
- /* unsigned long for convenience). In practice, two bytes */
+ /* maximum number of glyphs + 2; this is 0xFFFF + 2, thus */
+ /* explaining why `record_size' is a long (which we read as */
+ /* unsigned long for convenience). In practice, two bytes are */
/* sufficient to hold the size value. */
/* */
/* There are at least two fonts, HANNOM-A and HANNOM-B version */
@@ -522,8 +522,10 @@
record_size &= 0xFFFFU;
/* The limit for `num_records' is a heuristic value. */
-
- if ( version != 0 || num_records > 255 || record_size > 0x10001L )
+ if ( version != 0 ||
+ num_records > 255 ||
+ record_size > 0x10001L ||
+ record_size < 4 )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
|
CWE-125
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.