idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
8,200
|
ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face );
FT_Renderer result = library->cur_renderer;
if ( !result || result->glyph_format != slot->format )
result = FT_Lookup_Renderer( library, slot->format, 0 );
return result;
}
|
DoS Exec Code Overflow
| 0
|
ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face );
FT_Renderer result = library->cur_renderer;
if ( !result || result->glyph_format != slot->format )
result = FT_Lookup_Renderer( library, slot->format, 0 );
return result;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,201
|
ft_recompute_scaled_metrics( FT_Face face,
FT_Size_Metrics* metrics )
{
/* Compute root ascender, descender, test height, and max_advance */
#ifdef GRID_FIT_METRICS
metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
metrics->y_scale ) );
metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender,
metrics->y_scale ) );
metrics->height = FT_PIX_ROUND( FT_MulFix( face->height,
metrics->y_scale ) );
metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
metrics->x_scale ) );
#else /* !GRID_FIT_METRICS */
metrics->ascender = FT_MulFix( face->ascender,
metrics->y_scale );
metrics->descender = FT_MulFix( face->descender,
metrics->y_scale );
metrics->height = FT_MulFix( face->height,
metrics->y_scale );
metrics->max_advance = FT_MulFix( face->max_advance_width,
metrics->x_scale );
#endif /* !GRID_FIT_METRICS */
}
|
DoS Exec Code Overflow
| 0
|
ft_recompute_scaled_metrics( FT_Face face,
FT_Size_Metrics* metrics )
{
/* Compute root ascender, descender, test height, and max_advance */
#ifdef GRID_FIT_METRICS
metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
metrics->y_scale ) );
metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender,
metrics->y_scale ) );
metrics->height = FT_PIX_ROUND( FT_MulFix( face->height,
metrics->y_scale ) );
metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
metrics->x_scale ) );
#else /* !GRID_FIT_METRICS */
metrics->ascender = FT_MulFix( face->ascender,
metrics->y_scale );
metrics->descender = FT_MulFix( face->descender,
metrics->y_scale );
metrics->height = FT_MulFix( face->height,
metrics->y_scale );
metrics->max_advance = FT_MulFix( face->max_advance_width,
metrics->x_scale );
#endif /* !GRID_FIT_METRICS */
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,202
|
ft_set_current_renderer( FT_Library library )
{
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
library->cur_renderer = renderer;
}
|
DoS Exec Code Overflow
| 0
|
ft_set_current_renderer( FT_Library library )
{
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
library->cur_renderer = renderer;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,203
|
ft_stub_set_char_sizes( FT_Size size,
FT_F26Dot6 width,
FT_F26Dot6 height,
FT_UInt horz_res,
FT_UInt vert_res )
{
FT_Size_RequestRec req;
FT_Driver driver = size->face->driver;
if ( driver->clazz->request_size )
{
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = width;
req.height = height;
if ( horz_res == 0 )
horz_res = vert_res;
if ( vert_res == 0 )
vert_res = horz_res;
if ( horz_res == 0 )
horz_res = vert_res = 72;
req.horiResolution = horz_res;
req.vertResolution = vert_res;
return driver->clazz->request_size( size, &req );
}
return 0;
}
|
DoS Exec Code Overflow
| 0
|
ft_stub_set_char_sizes( FT_Size size,
FT_F26Dot6 width,
FT_F26Dot6 height,
FT_UInt horz_res,
FT_UInt vert_res )
{
FT_Size_RequestRec req;
FT_Driver driver = size->face->driver;
if ( driver->clazz->request_size )
{
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = width;
req.height = height;
if ( horz_res == 0 )
horz_res = vert_res;
if ( vert_res == 0 )
vert_res = horz_res;
if ( horz_res == 0 )
horz_res = vert_res = 72;
req.horiResolution = horz_res;
req.vertResolution = vert_res;
return driver->clazz->request_size( size, &req );
}
return 0;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,204
|
ft_stub_set_pixel_sizes( FT_Size size,
FT_UInt width,
FT_UInt height )
{
FT_Size_RequestRec req;
FT_Driver driver = size->face->driver;
if ( driver->clazz->request_size )
{
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = width << 6;
req.height = height << 6;
req.horiResolution = 0;
req.vertResolution = 0;
return driver->clazz->request_size( size, &req );
}
return 0;
}
|
DoS Exec Code Overflow
| 0
|
ft_stub_set_pixel_sizes( FT_Size size,
FT_UInt width,
FT_UInt height )
{
FT_Size_RequestRec req;
FT_Driver driver = size->face->driver;
if ( driver->clazz->request_size )
{
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = width << 6;
req.height = height << 6;
req.horiResolution = 0;
req.vertResolution = 0;
return driver->clazz->request_size( size, &req );
}
return 0;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,205
|
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance )
{
FT_Pos height = metrics->height;
/* compensate for glyph with bbox above/below the baseline */
if ( metrics->horiBearingY < 0 )
{
if ( height < metrics->horiBearingY )
height = metrics->horiBearingY;
}
else if ( metrics->horiBearingY > 0 )
height -= metrics->horiBearingY;
/* the factor 1.2 is a heuristical value */
if ( !advance )
advance = height * 12 / 10;
metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance;
}
|
DoS Exec Code Overflow
| 0
|
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance )
{
FT_Pos height = metrics->height;
/* compensate for glyph with bbox above/below the baseline */
if ( metrics->horiBearingY < 0 )
{
if ( height < metrics->horiBearingY )
height = metrics->horiBearingY;
}
else if ( metrics->horiBearingY > 0 )
height -= metrics->horiBearingY;
/* the factor 1.2 is a heuristical value */
if ( !advance )
advance = height * 12 / 10;
metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,206
|
load_face_in_embedded_rfork( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
FT_Memory memory = library->memory;
FT_Error error = FT_Err_Unknown_File_Format;
int i;
char * file_names[FT_RACCESS_N_RULES];
FT_Long offsets[FT_RACCESS_N_RULES];
FT_Error errors[FT_RACCESS_N_RULES];
FT_Open_Args args2;
FT_Stream stream2 = 0;
FT_Raccess_Guess( library, stream,
args->pathname, file_names, offsets, errors );
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
if ( errors[i] )
{
FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i ));
continue;
}
args2.flags = FT_OPEN_PATHNAME;
args2.pathname = file_names[i] ? file_names[i] : args->pathname;
FT_TRACE3(( "Try rule %d: %s (offset=%d) ...",
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
if ( error )
{
FT_TRACE3(( "failed\n" ));
continue;
}
error = IsMacResource( library, stream2, offsets[i],
face_index, aface );
FT_Stream_Free( stream2, 0 );
FT_TRACE3(( "%s\n", error ? "failed": "successful" ));
if ( !error )
break;
}
for (i = 0; i < FT_RACCESS_N_RULES; i++)
{
if ( file_names[i] )
FT_FREE( file_names[i] );
}
/* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
if ( error )
error = FT_Err_Unknown_File_Format;
return error;
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
}
|
DoS Exec Code Overflow
| 0
|
load_face_in_embedded_rfork( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
FT_Memory memory = library->memory;
FT_Error error = FT_Err_Unknown_File_Format;
int i;
char * file_names[FT_RACCESS_N_RULES];
FT_Long offsets[FT_RACCESS_N_RULES];
FT_Error errors[FT_RACCESS_N_RULES];
FT_Open_Args args2;
FT_Stream stream2 = 0;
FT_Raccess_Guess( library, stream,
args->pathname, file_names, offsets, errors );
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
if ( errors[i] )
{
FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i ));
continue;
}
args2.flags = FT_OPEN_PATHNAME;
args2.pathname = file_names[i] ? file_names[i] : args->pathname;
FT_TRACE3(( "Try rule %d: %s (offset=%d) ...",
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
if ( error )
{
FT_TRACE3(( "failed\n" ));
continue;
}
error = IsMacResource( library, stream2, offsets[i],
face_index, aface );
FT_Stream_Free( stream2, 0 );
FT_TRACE3(( "%s\n", error ? "failed": "successful" ));
if ( !error )
break;
}
for (i = 0; i < FT_RACCESS_N_RULES; i++)
{
if ( file_names[i] )
FT_FREE( file_names[i] );
}
/* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
if ( error )
error = FT_Err_Unknown_File_Format;
return error;
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,207
|
load_mac_face( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
FT_Error error;
FT_UNUSED( args );
error = IsMacBinary( library, stream, face_index, aface );
if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format )
{
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
FT_TRACE3(( "Try as dfont: %s ...", args->pathname ));
error = IsMacResource( library, stream, 0, face_index, aface );
FT_TRACE3(( "%s\n", error ? "failed" : "successful" ));
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
}
if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ||
FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) &&
( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
}
|
DoS Exec Code Overflow
| 0
|
load_mac_face( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
FT_Error error;
FT_UNUSED( args );
error = IsMacBinary( library, stream, face_index, aface );
if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format )
{
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
FT_TRACE3(( "Try as dfont: %s ...", args->pathname ));
error = IsMacResource( library, stream, 0, face_index, aface );
FT_TRACE3(( "%s\n", error ? "failed" : "successful" ));
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
}
if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ||
FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) &&
( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,208
|
memory_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( stream->base );
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
|
DoS Exec Code Overflow
| 0
|
memory_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( stream->base );
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,209
|
new_memory_stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream_CloseFunc close,
FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !base )
return FT_Err_Invalid_Argument;
*astream = 0;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
FT_Stream_OpenMemory( stream, base, size );
stream->close = close;
*astream = stream;
Exit:
return error;
}
|
DoS Exec Code Overflow
| 0
|
new_memory_stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream_CloseFunc close,
FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !base )
return FT_Err_Invalid_Argument;
*astream = 0;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
FT_Stream_OpenMemory( stream, base, size );
stream->close = close;
*astream = stream;
Exit:
return error;
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,210
|
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface )
{
FT_Error error;
FT_Memory memory = library->memory;
FT_ULong offset, length;
FT_Long pos;
FT_Bool is_sfnt_cid;
FT_Byte* sfnt_ps;
FT_UNUSED( num_params );
FT_UNUSED( params );
pos = FT_Stream_Pos( stream );
error = ft_lookup_PS_in_sfnt_stream( stream,
face_index,
&offset,
&length,
&is_sfnt_cid );
if ( error )
goto Exit;
if ( FT_Stream_Seek( stream, pos + offset ) )
goto Exit;
if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
if ( error )
goto Exit;
error = open_face_from_buffer( library,
sfnt_ps,
length,
face_index < 0 ? face_index : 0,
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
{
FT_Error error1;
if ( error == FT_Err_Unknown_File_Format )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
return error1;
}
return error;
}
}
|
DoS Exec Code Overflow
| 0
|
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface )
{
FT_Error error;
FT_Memory memory = library->memory;
FT_ULong offset, length;
FT_Long pos;
FT_Bool is_sfnt_cid;
FT_Byte* sfnt_ps;
FT_UNUSED( num_params );
FT_UNUSED( params );
pos = FT_Stream_Pos( stream );
error = ft_lookup_PS_in_sfnt_stream( stream,
face_index,
&offset,
&length,
&is_sfnt_cid );
if ( error )
goto Exit;
if ( FT_Stream_Seek( stream, pos + offset ) )
goto Exit;
if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
if ( error )
goto Exit;
error = open_face_from_buffer( library,
sfnt_ps,
length,
face_index < 0 ? face_index : 0,
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
{
FT_Error error1;
if ( error == FT_Err_Unknown_File_Format )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
return error1;
}
return error;
}
}
|
@@ -1550,6 +1550,9 @@
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
+ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
+ continue;
+
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
|
CWE-119
| null | null |
8,211
|
gray_compute_cbox( RAS_ARG )
{
FT_Outline* outline = &ras.outline;
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
if ( outline->n_points <= 0 )
{
ras.min_ex = ras.max_ex = 0;
ras.min_ey = ras.max_ey = 0;
return;
}
ras.min_ex = ras.max_ex = vec->x;
ras.min_ey = ras.max_ey = vec->y;
vec++;
for ( ; vec < limit; vec++ )
{
TPos x = vec->x;
TPos y = vec->y;
if ( x < ras.min_ex ) ras.min_ex = x;
if ( x > ras.max_ex ) ras.max_ex = x;
if ( y < ras.min_ey ) ras.min_ey = y;
if ( y > ras.max_ey ) ras.max_ey = y;
}
/* truncate the bounding box to integer pixels */
ras.min_ex = ras.min_ex >> 6;
ras.min_ey = ras.min_ey >> 6;
ras.max_ex = ( ras.max_ex + 63 ) >> 6;
ras.max_ey = ( ras.max_ey + 63 ) >> 6;
}
|
DoS Exec Code Overflow
| 0
|
gray_compute_cbox( RAS_ARG )
{
FT_Outline* outline = &ras.outline;
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
if ( outline->n_points <= 0 )
{
ras.min_ex = ras.max_ex = 0;
ras.min_ey = ras.max_ey = 0;
return;
}
ras.min_ex = ras.max_ex = vec->x;
ras.min_ey = ras.max_ey = vec->y;
vec++;
for ( ; vec < limit; vec++ )
{
TPos x = vec->x;
TPos y = vec->y;
if ( x < ras.min_ex ) ras.min_ex = x;
if ( x > ras.max_ex ) ras.max_ex = x;
if ( y < ras.min_ey ) ras.min_ey = y;
if ( y > ras.max_ey ) ras.max_ey = y;
}
/* truncate the bounding box to integer pixels */
ras.min_ex = ras.min_ex >> 6;
ras.min_ey = ras.min_ey >> 6;
ras.max_ex = ( ras.max_ex + 63 ) >> 6;
ras.max_ey = ( ras.max_ey + 63 ) >> 6;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,212
|
gray_conic_to( const FT_Vector* control,
const FT_Vector* to,
PWorker worker )
{
gray_render_conic( RAS_VAR_ control, to );
return 0;
}
|
DoS Exec Code Overflow
| 0
|
gray_conic_to( const FT_Vector* control,
const FT_Vector* to,
PWorker worker )
{
gray_render_conic( RAS_VAR_ control, to );
return 0;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,213
|
gray_convert_glyph( RAS_ARG )
{
TBand bands[40];
TBand* volatile band;
int volatile n, num_bands;
TPos volatile min, max, max_y;
FT_BBox* clip;
/* Set up state in the raster object */
gray_compute_cbox( RAS_VAR );
/* clip to target bitmap, exit if nothing to do */
clip = &ras.clip_box;
if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
return 0;
if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* simple heuristic used to speed up the bezier decomposition -- see */
/* the code in gray_render_conic() and gray_render_cubic() for more */
/* details */
ras.conic_level = 32;
ras.cubic_level = 16;
{
int level = 0;
if ( ras.count_ex > 24 || ras.count_ey > 24 )
level++;
if ( ras.count_ex > 120 || ras.count_ey > 120 )
level++;
ras.conic_level <<= level;
ras.cubic_level <<= level;
}
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
num_bands = 39;
ras.band_shoot = 0;
min = ras.min_ey;
max_y = ras.max_ey;
for ( n = 0; n < num_bands; n++, min = max )
{
max = min + ras.band_size;
if ( n == num_bands - 1 || max > max_y )
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = bands;
while ( band >= bands )
{
TPos bottom, top, middle;
int error;
{
PCell cells_max;
int yindex;
long cell_start, cell_end, cell_mod;
ras.ycells = (PCell*)ras.buffer;
ras.ycount = band->max - band->min;
cell_start = sizeof ( PCell ) * ras.ycount;
cell_mod = cell_start % sizeof ( TCell );
if ( cell_mod > 0 )
cell_start += sizeof ( TCell ) - cell_mod;
cell_end = ras.buffer_size;
cell_end -= cell_end % sizeof( TCell );
cells_max = (PCell)( (char*)ras.buffer + cell_end );
ras.cells = (PCell)( (char*)ras.buffer + cell_start );
if ( ras.cells >= cells_max )
goto ReduceBands;
ras.max_cells = cells_max - ras.cells;
if ( ras.max_cells < 2 )
goto ReduceBands;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
ras.ycells[yindex] = NULL;
}
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = band->min;
ras.max_ey = band->max;
ras.count_ey = band->max - band->min;
error = gray_convert_glyph_inner( RAS_VAR );
if ( !error )
{
gray_sweep( RAS_VAR_ &ras.target );
band--;
continue;
}
else if ( error != ErrRaster_Memory_Overflow )
return 1;
ReduceBands:
/* render pool overflow; we will reduce the render band by half */
bottom = band->min;
top = band->max;
middle = bottom + ( ( top - bottom ) >> 1 );
/* This is too complex for a single scanline; there must */
/* be some problems. */
if ( middle == bottom )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
#endif
return 1;
}
if ( bottom-top >= ras.band_size )
ras.band_shoot++;
band[1].min = bottom;
band[1].max = middle;
band[0].min = middle;
band[0].max = top;
band++;
}
}
if ( ras.band_shoot > 8 && ras.band_size > 16 )
ras.band_size = ras.band_size / 2;
return 0;
}
|
DoS Exec Code Overflow
| 0
|
gray_convert_glyph( RAS_ARG )
{
TBand bands[40];
TBand* volatile band;
int volatile n, num_bands;
TPos volatile min, max, max_y;
FT_BBox* clip;
/* Set up state in the raster object */
gray_compute_cbox( RAS_VAR );
/* clip to target bitmap, exit if nothing to do */
clip = &ras.clip_box;
if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
return 0;
if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* simple heuristic used to speed up the bezier decomposition -- see */
/* the code in gray_render_conic() and gray_render_cubic() for more */
/* details */
ras.conic_level = 32;
ras.cubic_level = 16;
{
int level = 0;
if ( ras.count_ex > 24 || ras.count_ey > 24 )
level++;
if ( ras.count_ex > 120 || ras.count_ey > 120 )
level++;
ras.conic_level <<= level;
ras.cubic_level <<= level;
}
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
num_bands = 39;
ras.band_shoot = 0;
min = ras.min_ey;
max_y = ras.max_ey;
for ( n = 0; n < num_bands; n++, min = max )
{
max = min + ras.band_size;
if ( n == num_bands - 1 || max > max_y )
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = bands;
while ( band >= bands )
{
TPos bottom, top, middle;
int error;
{
PCell cells_max;
int yindex;
long cell_start, cell_end, cell_mod;
ras.ycells = (PCell*)ras.buffer;
ras.ycount = band->max - band->min;
cell_start = sizeof ( PCell ) * ras.ycount;
cell_mod = cell_start % sizeof ( TCell );
if ( cell_mod > 0 )
cell_start += sizeof ( TCell ) - cell_mod;
cell_end = ras.buffer_size;
cell_end -= cell_end % sizeof( TCell );
cells_max = (PCell)( (char*)ras.buffer + cell_end );
ras.cells = (PCell)( (char*)ras.buffer + cell_start );
if ( ras.cells >= cells_max )
goto ReduceBands;
ras.max_cells = cells_max - ras.cells;
if ( ras.max_cells < 2 )
goto ReduceBands;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
ras.ycells[yindex] = NULL;
}
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = band->min;
ras.max_ey = band->max;
ras.count_ey = band->max - band->min;
error = gray_convert_glyph_inner( RAS_VAR );
if ( !error )
{
gray_sweep( RAS_VAR_ &ras.target );
band--;
continue;
}
else if ( error != ErrRaster_Memory_Overflow )
return 1;
ReduceBands:
/* render pool overflow; we will reduce the render band by half */
bottom = band->min;
top = band->max;
middle = bottom + ( ( top - bottom ) >> 1 );
/* This is too complex for a single scanline; there must */
/* be some problems. */
if ( middle == bottom )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
#endif
return 1;
}
if ( bottom-top >= ras.band_size )
ras.band_shoot++;
band[1].min = bottom;
band[1].max = middle;
band[0].min = middle;
band[0].max = top;
band++;
}
}
if ( ras.band_shoot > 8 && ras.band_size > 16 )
ras.band_size = ras.band_size / 2;
return 0;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,214
|
gray_convert_glyph_inner( RAS_ARG )
{
volatile int error = 0;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs func_interface;
Init_Class_func_interface(&func_interface);
#endif
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
gray_record_cell( RAS_VAR );
}
else
error = ErrRaster_Memory_Overflow;
return error;
}
|
DoS Exec Code Overflow
| 0
|
gray_convert_glyph_inner( RAS_ARG )
{
volatile int error = 0;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs func_interface;
Init_Class_func_interface(&func_interface);
#endif
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
gray_record_cell( RAS_VAR );
}
else
error = ErrRaster_Memory_Overflow;
return error;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,215
|
gray_cubic_to( const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
PWorker worker )
{
gray_render_cubic( RAS_VAR_ control1, control2, to );
return 0;
}
|
DoS Exec Code Overflow
| 0
|
gray_cubic_to( const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
PWorker worker )
{
gray_render_cubic( RAS_VAR_ control1, control2, to );
return 0;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,216
|
gray_dump_cells( RAS_ARG )
{
int yindex;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell;
printf( "%3d:", yindex );
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area );
printf( "\n" );
}
}
|
DoS Exec Code Overflow
| 0
|
gray_dump_cells( RAS_ARG )
{
int yindex;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell;
printf( "%3d:", yindex );
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area );
printf( "\n" );
}
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,217
|
gray_find_cell( RAS_ARG )
{
PCell *pcell, cell;
TPos x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
pcell = &ras.ycells[ras.ey];
for (;;)
{
cell = *pcell;
if ( cell == NULL || cell->x > x )
break;
if ( cell->x == x )
goto Exit;
pcell = &cell->next;
}
if ( ras.num_cells >= ras.max_cells )
ft_longjmp( ras.jump_buffer, 1 );
cell = ras.cells + ras.num_cells++;
cell->x = x;
cell->area = 0;
cell->cover = 0;
cell->next = *pcell;
*pcell = cell;
Exit:
return cell;
}
|
DoS Exec Code Overflow
| 0
|
gray_find_cell( RAS_ARG )
{
PCell *pcell, cell;
TPos x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
pcell = &ras.ycells[ras.ey];
for (;;)
{
cell = *pcell;
if ( cell == NULL || cell->x > x )
break;
if ( cell->x == x )
goto Exit;
pcell = &cell->next;
}
if ( ras.num_cells >= ras.max_cells )
ft_longjmp( ras.jump_buffer, 1 );
cell = ras.cells + ras.num_cells++;
cell->x = x;
cell->area = 0;
cell->cover = 0;
cell->next = *pcell;
*pcell = cell;
Exit:
return cell;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,218
|
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TPos area,
TCoord acount )
{
FT_Span* span;
int count;
int coverage;
/* compute the coverage line's coverage, depending on the */
/* outline fill rule */
/* */
/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
/* */
coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );
/* use range 0..256 */
if ( coverage < 0 )
coverage = -coverage;
if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
{
coverage &= 511;
if ( coverage > 256 )
coverage = 512 - coverage;
else if ( coverage == 256 )
coverage = 255;
}
else
{
/* normal non-zero winding rule */
if ( coverage >= 256 )
coverage = 255;
}
y += (TCoord)ras.min_ey;
x += (TCoord)ras.min_ex;
/* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
if ( x >= 32767 )
x = 32767;
/* FT_Span.y is an integer, so limit our coordinates appropriately */
if ( y >= FT_INT_MAX )
y = FT_INT_MAX;
if ( coverage )
{
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
if ( count > 0 &&
ras.span_y == y &&
(int)span->x + span->len == (int)x &&
span->coverage == coverage )
{
span->len = (unsigned short)( span->len + acount );
return;
}
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
{
if ( ras.render_span && count > 0 )
ras.render_span( ras.span_y, count, ras.gray_spans,
ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( count > 0 )
{
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < count; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
ras.num_gray_spans = 0;
ras.span_y = (int)y;
count = 0;
span = ras.gray_spans;
}
else
span++;
/* add a gray span to the current list */
span->x = (short)x;
span->len = (unsigned short)acount;
span->coverage = (unsigned char)coverage;
ras.num_gray_spans++;
}
}
|
DoS Exec Code Overflow
| 0
|
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TPos area,
TCoord acount )
{
FT_Span* span;
int count;
int coverage;
/* compute the coverage line's coverage, depending on the */
/* outline fill rule */
/* */
/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
/* */
coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );
/* use range 0..256 */
if ( coverage < 0 )
coverage = -coverage;
if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
{
coverage &= 511;
if ( coverage > 256 )
coverage = 512 - coverage;
else if ( coverage == 256 )
coverage = 255;
}
else
{
/* normal non-zero winding rule */
if ( coverage >= 256 )
coverage = 255;
}
y += (TCoord)ras.min_ey;
x += (TCoord)ras.min_ex;
/* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
if ( x >= 32767 )
x = 32767;
/* FT_Span.y is an integer, so limit our coordinates appropriately */
if ( y >= FT_INT_MAX )
y = FT_INT_MAX;
if ( coverage )
{
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
if ( count > 0 &&
ras.span_y == y &&
(int)span->x + span->len == (int)x &&
span->coverage == coverage )
{
span->len = (unsigned short)( span->len + acount );
return;
}
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
{
if ( ras.render_span && count > 0 )
ras.render_span( ras.span_y, count, ras.gray_spans,
ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( count > 0 )
{
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < count; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
ras.num_gray_spans = 0;
ras.span_y = (int)y;
count = 0;
span = ras.gray_spans;
}
else
span++;
/* add a gray span to the current list */
span->x = (short)x;
span->len = (unsigned short)acount;
span->coverage = (unsigned char)coverage;
ras.num_gray_spans++;
}
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,219
|
gray_init_cells( RAS_ARG_ void* buffer,
long byte_size )
{
ras.buffer = buffer;
ras.buffer_size = byte_size;
ras.ycells = (PCell*) buffer;
ras.cells = NULL;
ras.max_cells = 0;
ras.num_cells = 0;
ras.area = 0;
ras.cover = 0;
ras.invalid = 1;
}
|
DoS Exec Code Overflow
| 0
|
gray_init_cells( RAS_ARG_ void* buffer,
long byte_size )
{
ras.buffer = buffer;
ras.buffer_size = byte_size;
ras.ycells = (PCell*) buffer;
ras.cells = NULL;
ras.max_cells = 0;
ras.num_cells = 0;
ras.area = 0;
ras.cover = 0;
ras.invalid = 1;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,220
|
gray_line_to( const FT_Vector* to,
PWorker worker )
{
gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
return 0;
}
|
DoS Exec Code Overflow
| 0
|
gray_line_to( const FT_Vector* to,
PWorker worker )
{
gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
return 0;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,221
|
gray_raster_done( FT_Raster raster )
{
/* nothing */
FT_UNUSED( raster );
}
|
DoS Exec Code Overflow
| 0
|
gray_raster_done( FT_Raster raster )
{
/* nothing */
FT_UNUSED( raster );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,222
|
gray_raster_done( FT_Raster raster )
{
FT_Memory memory = (FT_Memory)((PRaster)raster)->memory;
FT_FREE( raster );
}
|
DoS Exec Code Overflow
| 0
|
gray_raster_done( FT_Raster raster )
{
FT_Memory memory = (FT_Memory)((PRaster)raster)->memory;
FT_FREE( raster );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,223
|
gray_raster_new( void* memory,
FT_Raster* araster )
{
static TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
return 0;
}
|
DoS Exec Code Overflow
| 0
|
gray_raster_new( void* memory,
FT_Raster* araster )
{
static TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
return 0;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,224
|
gray_raster_new( FT_Memory memory,
FT_Raster* araster )
{
FT_Error error;
PRaster raster;
*araster = 0;
if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) )
{
raster->memory = memory;
*araster = (FT_Raster)raster;
}
return error;
}
|
DoS Exec Code Overflow
| 0
|
gray_raster_new( FT_Memory memory,
FT_Raster* araster )
{
FT_Error error;
PRaster raster;
*araster = 0;
if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) )
{
raster->memory = memory;
*araster = (FT_Raster)raster;
}
return error;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,225
|
gray_raster_render( PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return ErrRaster_Invalid_Argument;
if ( !outline )
return ErrRaster_Invalid_Outline;
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
return ErrRaster_Invalid_Outline;
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return ErrRaster_Invalid_Outline;
worker = raster->worker;
/* if direct mode is not set, we must have a target bitmap */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
return ErrRaster_Invalid_Argument;
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
return ErrRaster_Invalid_Argument;
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return ErrRaster_Invalid_Mode;
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
/* compute clip box from target pixmap */
ras.clip_box.xMin = 0;
ras.clip_box.yMin = 0;
ras.clip_box.xMax = target_map->width;
ras.clip_box.yMax = target_map->rows;
}
else if ( params->flags & FT_RASTER_FLAG_CLIP )
ras.clip_box = params->clip_box;
else
{
ras.clip_box.xMin = -32768L;
ras.clip_box.yMin = -32768L;
ras.clip_box.xMax = 32767L;
ras.clip_box.yMax = 32767L;
}
gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.num_gray_spans = 0;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
ras.target = *target_map;
ras.render_span = (FT_Raster_Span_Func)gray_render_span;
ras.render_span_data = &ras;
}
return gray_convert_glyph( RAS_VAR );
}
|
DoS Exec Code Overflow
| 0
|
gray_raster_render( PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return ErrRaster_Invalid_Argument;
if ( !outline )
return ErrRaster_Invalid_Outline;
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
return ErrRaster_Invalid_Outline;
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return ErrRaster_Invalid_Outline;
worker = raster->worker;
/* if direct mode is not set, we must have a target bitmap */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
return ErrRaster_Invalid_Argument;
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
return ErrRaster_Invalid_Argument;
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return ErrRaster_Invalid_Mode;
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
/* compute clip box from target pixmap */
ras.clip_box.xMin = 0;
ras.clip_box.yMin = 0;
ras.clip_box.xMax = target_map->width;
ras.clip_box.yMax = target_map->rows;
}
else if ( params->flags & FT_RASTER_FLAG_CLIP )
ras.clip_box = params->clip_box;
else
{
ras.clip_box.xMin = -32768L;
ras.clip_box.yMin = -32768L;
ras.clip_box.xMax = 32767L;
ras.clip_box.yMax = 32767L;
}
gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.num_gray_spans = 0;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
ras.target = *target_map;
ras.render_span = (FT_Raster_Span_Func)gray_render_span;
ras.render_span_data = &ras;
}
return gray_convert_glyph( RAS_VAR );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,226
|
gray_render_conic( RAS_ARG_ const FT_Vector* control,
const FT_Vector* to )
{
TPos dx, dy;
int top, level;
int* levels;
FT_Vector* arc;
dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 );
if ( dx < 0 )
dx = -dx;
dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 );
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx = dx / ras.conic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
/* a shortcut to speed things up */
if ( level <= 1 )
{
/* we compute the mid-point directly in order to avoid */
/* calling gray_split_conic() */
TPos to_x, to_y, mid_x, mid_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
mid_x = ( ras.x + to_x + 2 * UPSCALE( control->x ) ) / 4;
mid_y = ( ras.y + to_y + 2 * UPSCALE( control->y ) ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control->x );
arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x;
arc[2].y = ras.y;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw;
gray_split_conic( arc );
arc += 2;
top++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y, mid_x, mid_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 2 * arc[1].x ) / 4;
mid_y = ( ras.y + to_y + 2 * arc[1].y ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top--;
arc -= 2;
}
}
return;
}
|
DoS Exec Code Overflow
| 0
|
gray_render_conic( RAS_ARG_ const FT_Vector* control,
const FT_Vector* to )
{
TPos dx, dy;
int top, level;
int* levels;
FT_Vector* arc;
dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 );
if ( dx < 0 )
dx = -dx;
dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 );
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx = dx / ras.conic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
/* a shortcut to speed things up */
if ( level <= 1 )
{
/* we compute the mid-point directly in order to avoid */
/* calling gray_split_conic() */
TPos to_x, to_y, mid_x, mid_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
mid_x = ( ras.x + to_x + 2 * UPSCALE( control->x ) ) / 4;
mid_y = ( ras.y + to_y + 2 * UPSCALE( control->y ) ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control->x );
arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x;
arc[2].y = ras.y;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw;
gray_split_conic( arc );
arc += 2;
top++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y, mid_x, mid_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 2 * arc[1].x ) / 4;
mid_y = ( ras.y + to_y + 2 * arc[1].y ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top--;
arc -= 2;
}
}
return;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,227
|
gray_render_cubic( RAS_ARG_ const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to )
{
int top, level;
int* levels;
FT_Vector* arc;
int mid_x = ( DOWNSCALE( ras.x ) + to->x +
3 * (control1->x + control2->x ) ) / 8;
int mid_y = ( DOWNSCALE( ras.y ) + to->y +
3 * (control1->y + control2->y ) ) / 8;
TPos dx = DOWNSCALE( ras.x ) + to->x - ( mid_x << 1 );
TPos dy = DOWNSCALE( ras.y ) + to->y - ( mid_y << 1 );
if ( dx < 0 )
dx = -dx;
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx /= ras.cubic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
if ( level <= 1 )
{
TPos to_x, to_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
/* Recalculation of midpoint is needed only if */
/* UPSCALE and DOWNSCALE have any effect. */
#if ( PIXEL_BITS != 6 )
mid_x = ( ras.x + to_x +
3 * UPSCALE( control1->x + control2->x ) ) / 8;
mid_y = ( ras.y + to_y +
3 * UPSCALE( control1->y + control2->y ) ) / 8;
#endif
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control2->x );
arc[1].y = UPSCALE( control2->y );
arc[2].x = UPSCALE( control1->x );
arc[2].y = UPSCALE( control1->y );
arc[3].x = ras.x;
arc[3].y = ras.y;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[3].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < 0 )
goto Draw;
gray_split_cubic( arc );
arc += 3;
top ++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 3 * ( arc[1].x + arc[2].x ) ) / 8;
mid_y = ( ras.y + to_y + 3 * ( arc[1].y + arc[2].y ) ) / 8;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top --;
arc -= 3;
}
}
return;
}
|
DoS Exec Code Overflow
| 0
|
gray_render_cubic( RAS_ARG_ const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to )
{
int top, level;
int* levels;
FT_Vector* arc;
int mid_x = ( DOWNSCALE( ras.x ) + to->x +
3 * (control1->x + control2->x ) ) / 8;
int mid_y = ( DOWNSCALE( ras.y ) + to->y +
3 * (control1->y + control2->y ) ) / 8;
TPos dx = DOWNSCALE( ras.x ) + to->x - ( mid_x << 1 );
TPos dy = DOWNSCALE( ras.y ) + to->y - ( mid_y << 1 );
if ( dx < 0 )
dx = -dx;
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx /= ras.cubic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
if ( level <= 1 )
{
TPos to_x, to_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
/* Recalculation of midpoint is needed only if */
/* UPSCALE and DOWNSCALE have any effect. */
#if ( PIXEL_BITS != 6 )
mid_x = ( ras.x + to_x +
3 * UPSCALE( control1->x + control2->x ) ) / 8;
mid_y = ( ras.y + to_y +
3 * UPSCALE( control1->y + control2->y ) ) / 8;
#endif
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control2->x );
arc[1].y = UPSCALE( control2->y );
arc[2].x = UPSCALE( control1->x );
arc[2].y = UPSCALE( control1->y );
arc[3].x = ras.x;
arc[3].y = ras.y;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[3].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < 0 )
goto Draw;
gray_split_cubic( arc );
arc += 3;
top ++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 3 * ( arc[1].x + arc[2].x ) ) / 8;
mid_y = ( ras.y + to_y + 3 * ( arc[1].y + arc[2].y ) ) / 8;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top --;
arc -= 3;
}
}
return;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,228
|
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
TCoord ey1, ey2, fy1, fy2, mod;
TPos dx, dy, x, x2;
long p, first;
int delta, rem, lift, incr;
ey1 = TRUNC( ras.last_ey );
ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
fy1 = (TCoord)( ras.y - ras.last_ey );
fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
dx = to_x - ras.x;
dy = to_y - ras.y;
/* XXX: we should do something about the trivial case where dx == 0, */
/* as it happens very often! */
/* perform vertical clipping */
{
TCoord min, max;
min = ey1;
max = ey2;
if ( ey1 > ey2 )
{
min = ey2;
max = ey1;
}
if ( min >= ras.max_ey || max < ras.min_ey )
goto End;
}
/* everything is on a single scanline */
if ( ey1 == ey2 )
{
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
goto End;
}
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 );
TArea area;
first = ONE_PIXEL;
if ( dy < 0 )
{
first = 0;
incr = -1;
}
delta = (int)( first - fy1 );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
delta = (int)( first + first - ONE_PIXEL );
area = (TArea)two_fx * delta;
while ( ey1 != ey2 )
{
ras.area += area;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
}
delta = (int)( fy2 - ONE_PIXEL + first );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
goto End;
}
/* ok, we have to render several scanlines */
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
if ( dy < 0 )
{
p = fy1 * dx;
first = 0;
incr = -1;
dy = -dy;
}
delta = (int)( p / dy );
mod = (int)( p % dy );
if ( mod < 0 )
{
delta--;
mod += (TCoord)dy;
}
x = ras.x + delta;
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
if ( ey1 != ey2 )
{
p = ONE_PIXEL * dx;
lift = (int)( p / dy );
rem = (int)( p % dy );
if ( rem < 0 )
{
lift--;
rem += (int)dy;
}
mod -= (int)dy;
while ( ey1 != ey2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (int)dy;
delta++;
}
x2 = x + delta;
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), x2,
(TCoord)first );
x = x2;
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
}
}
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), to_x,
fy2 );
End:
ras.x = to_x;
ras.y = to_y;
ras.last_ey = SUBPIXELS( ey2 );
}
|
DoS Exec Code Overflow
| 0
|
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
TCoord ey1, ey2, fy1, fy2, mod;
TPos dx, dy, x, x2;
long p, first;
int delta, rem, lift, incr;
ey1 = TRUNC( ras.last_ey );
ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
fy1 = (TCoord)( ras.y - ras.last_ey );
fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
dx = to_x - ras.x;
dy = to_y - ras.y;
/* XXX: we should do something about the trivial case where dx == 0, */
/* as it happens very often! */
/* perform vertical clipping */
{
TCoord min, max;
min = ey1;
max = ey2;
if ( ey1 > ey2 )
{
min = ey2;
max = ey1;
}
if ( min >= ras.max_ey || max < ras.min_ey )
goto End;
}
/* everything is on a single scanline */
if ( ey1 == ey2 )
{
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
goto End;
}
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 );
TArea area;
first = ONE_PIXEL;
if ( dy < 0 )
{
first = 0;
incr = -1;
}
delta = (int)( first - fy1 );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
delta = (int)( first + first - ONE_PIXEL );
area = (TArea)two_fx * delta;
while ( ey1 != ey2 )
{
ras.area += area;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
}
delta = (int)( fy2 - ONE_PIXEL + first );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
goto End;
}
/* ok, we have to render several scanlines */
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
if ( dy < 0 )
{
p = fy1 * dx;
first = 0;
incr = -1;
dy = -dy;
}
delta = (int)( p / dy );
mod = (int)( p % dy );
if ( mod < 0 )
{
delta--;
mod += (TCoord)dy;
}
x = ras.x + delta;
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
if ( ey1 != ey2 )
{
p = ONE_PIXEL * dx;
lift = (int)( p / dy );
rem = (int)( p % dy );
if ( rem < 0 )
{
lift--;
rem += (int)dy;
}
mod -= (int)dy;
while ( ey1 != ey2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (int)dy;
delta++;
}
x2 = x + delta;
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), x2,
(TCoord)first );
x = x2;
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
}
}
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), to_x,
fy2 );
End:
ras.x = to_x;
ras.y = to_y;
ras.last_ey = SUBPIXELS( ey2 );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,229
|
gray_set_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
/* Move the cell pointer to a new position. We set the `invalid' */
/* flag to indicate that the cell isn't part of those we're interested */
/* in during the render phase. This means that: */
/* */
/* . the new vertical position must be within min_ey..max_ey-1. */
/* . the new horizontal position must be strictly less than max_ex */
/* */
/* Note that if a cell is to the left of the clipping region, it is */
/* actually set to the (min_ex-1) horizontal position. */
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
{
/* record the current one if it is valid */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
ras.area = 0;
ras.cover = 0;
}
ras.ex = ex;
ras.ey = ey;
ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
ex >= ras.count_ex );
}
|
DoS Exec Code Overflow
| 0
|
gray_set_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
/* Move the cell pointer to a new position. We set the `invalid' */
/* flag to indicate that the cell isn't part of those we're interested */
/* in during the render phase. This means that: */
/* */
/* . the new vertical position must be within min_ey..max_ey-1. */
/* . the new horizontal position must be strictly less than max_ex */
/* */
/* Note that if a cell is to the left of the clipping region, it is */
/* actually set to the (min_ex-1) horizontal position. */
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
{
/* record the current one if it is valid */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
ras.area = 0;
ras.cover = 0;
}
ras.ex = ex;
ras.ey = ey;
ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
ex >= ras.count_ex );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,230
|
gray_split_conic( FT_Vector* base )
{
TPos a, b;
base[4].x = base[2].x;
b = base[1].x;
a = base[3].x = ( base[2].x + b ) / 2;
b = base[1].x = ( base[0].x + b ) / 2;
base[2].x = ( a + b ) / 2;
base[4].y = base[2].y;
b = base[1].y;
a = base[3].y = ( base[2].y + b ) / 2;
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
}
|
DoS Exec Code Overflow
| 0
|
gray_split_conic( FT_Vector* base )
{
TPos a, b;
base[4].x = base[2].x;
b = base[1].x;
a = base[3].x = ( base[2].x + b ) / 2;
b = base[1].x = ( base[0].x + b ) / 2;
base[2].x = ( a + b ) / 2;
base[4].y = base[2].y;
b = base[1].y;
a = base[3].y = ( base[2].y + b ) / 2;
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,231
|
gray_split_cubic( FT_Vector* base )
{
TPos a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
d = base[2].x;
base[1].x = a = ( base[0].x + c ) / 2;
base[5].x = b = ( base[3].x + d ) / 2;
c = ( c + d ) / 2;
base[2].x = a = ( a + c ) / 2;
base[4].x = b = ( b + c ) / 2;
base[3].x = ( a + b ) / 2;
base[6].y = base[3].y;
c = base[1].y;
d = base[2].y;
base[1].y = a = ( base[0].y + c ) / 2;
base[5].y = b = ( base[3].y + d ) / 2;
c = ( c + d ) / 2;
base[2].y = a = ( a + c ) / 2;
base[4].y = b = ( b + c ) / 2;
base[3].y = ( a + b ) / 2;
}
|
DoS Exec Code Overflow
| 0
|
gray_split_cubic( FT_Vector* base )
{
TPos a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
d = base[2].x;
base[1].x = a = ( base[0].x + c ) / 2;
base[5].x = b = ( base[3].x + d ) / 2;
c = ( c + d ) / 2;
base[2].x = a = ( a + c ) / 2;
base[4].x = b = ( b + c ) / 2;
base[3].x = ( a + b ) / 2;
base[6].y = base[3].y;
c = base[1].y;
d = base[2].y;
base[1].y = a = ( base[0].y + c ) / 2;
base[5].y = b = ( base[3].y + d ) / 2;
c = ( c + d ) / 2;
base[2].y = a = ( a + c ) / 2;
base[4].y = b = ( b + c ) / 2;
base[3].y = ( a + b ) / 2;
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,232
|
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
if ( ex > ras.max_ex )
ex = (TCoord)( ras.max_ex );
if ( ex < ras.min_ex )
ex = (TCoord)( ras.min_ex - 1 );
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.last_ey = SUBPIXELS( ey );
ras.invalid = 0;
gray_set_cell( RAS_VAR_ ex, ey );
}
|
DoS Exec Code Overflow
| 0
|
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
if ( ex > ras.max_ex )
ex = (TCoord)( ras.max_ex );
if ( ex < ras.min_ex )
ex = (TCoord)( ras.min_ex - 1 );
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.last_ey = SUBPIXELS( ey );
ras.invalid = 0;
gray_set_cell( RAS_VAR_ ex, ey );
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,233
|
gray_sweep( RAS_ARG_ const FT_Bitmap* target )
{
int yindex;
FT_UNUSED( target );
if ( ras.num_cells == 0 )
return;
ras.num_gray_spans = 0;
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell = ras.ycells[yindex];
TCoord cover = 0;
TCoord x = 0;
for ( ; cell != NULL; cell = cell->next )
{
TPos area;
if ( cell->x > x && cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
cell->x - x );
cover += cell->cover;
area = cover * ( ONE_PIXEL * 2 ) - cell->area;
if ( area != 0 && cell->x >= 0 )
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
x = cell->x + 1;
}
if ( cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
ras.count_ex - x );
}
if ( ras.render_span && ras.num_gray_spans > 0 )
ras.render_span( ras.span_y, ras.num_gray_spans,
ras.gray_spans, ras.render_span_data );
FT_TRACE7(( "gray_sweep: end\n" ));
}
|
DoS Exec Code Overflow
| 0
|
gray_sweep( RAS_ARG_ const FT_Bitmap* target )
{
int yindex;
FT_UNUSED( target );
if ( ras.num_cells == 0 )
return;
ras.num_gray_spans = 0;
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell = ras.ycells[yindex];
TCoord cover = 0;
TCoord x = 0;
for ( ; cell != NULL; cell = cell->next )
{
TPos area;
if ( cell->x > x && cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
cell->x - x );
cover += cell->cover;
area = cover * ( ONE_PIXEL * 2 ) - cell->area;
if ( area != 0 && cell->x >= 0 )
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
x = cell->x + 1;
}
if ( cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
ras.count_ex - x );
}
if ( ras.render_span && ras.num_gray_spans > 0 )
ras.render_span( ras.span_y, ras.num_gray_spans,
ras.gray_spans, ras.render_span_data );
FT_TRACE7(( "gray_sweep: end\n" ));
}
|
@@ -1186,7 +1186,7 @@
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
- p += ( map->rows - 1 ) * map->pitch;
+ p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
|
CWE-189
| null | null |
8,234
|
ps_hints_apply( PS_Hints ps_hints,
FT_Outline* outline,
PSH_Globals globals,
FT_Render_Mode hint_mode )
{
PSH_GlyphRec glyphrec;
PSH_Glyph glyph = &glyphrec;
FT_Error error;
#ifdef DEBUG_HINTER
FT_Memory memory;
#endif
FT_Int dimension;
/* something to do? */
if ( outline->n_points == 0 || outline->n_contours == 0 )
return PSH_Err_Ok;
#ifdef DEBUG_HINTER
memory = globals->memory;
if ( ps_debug_glyph )
{
psh_glyph_done( ps_debug_glyph );
FT_FREE( ps_debug_glyph );
}
if ( FT_NEW( glyph ) )
return error;
ps_debug_glyph = glyph;
#endif /* DEBUG_HINTER */
error = psh_glyph_init( glyph, outline, ps_hints, globals );
if ( error )
goto Exit;
/* try to optimize the y_scale so that the top of non-capital letters
* is aligned on a pixel boundary whenever possible
*/
{
PSH_Dimension dim_x = &glyph->globals->dimension[0];
PSH_Dimension dim_y = &glyph->globals->dimension[1];
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed old_x_scale = x_scale;
FT_Fixed old_y_scale = y_scale;
FT_Fixed scaled;
FT_Fixed fitted;
FT_Bool rescale = FALSE;
scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
fitted = FT_PIX_ROUND( scaled );
if ( fitted != 0 && scaled != fitted )
{
rescale = TRUE;
y_scale = FT_MulDiv( y_scale, fitted, scaled );
if ( fitted < scaled )
x_scale -= x_scale / 50;
psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
}
glyph->do_horz_hints = 1;
glyph->do_vert_hints = 1;
glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
psh_glyph_load_points( glyph, dimension );
/* compute local extrema */
psh_glyph_compute_extrema( glyph );
/* compute aligned stem/hints positions */
psh_hint_table_align_hints( &glyph->hint_tables[dimension],
glyph->globals,
dimension,
glyph );
/* find strong points, align them, then interpolate others */
psh_glyph_find_strong_points( glyph, dimension );
if ( dimension == 1 )
psh_glyph_find_blue_points( &globals->blues, glyph );
psh_glyph_interpolate_strong_points( glyph, dimension );
psh_glyph_interpolate_normal_points( glyph, dimension );
psh_glyph_interpolate_other_points( glyph, dimension );
/* save hinted coordinates back to outline */
psh_glyph_save_points( glyph, dimension );
if ( rescale )
psh_globals_set_scale( glyph->globals,
old_x_scale, old_y_scale, 0, 0 );
}
}
Exit:
#ifndef DEBUG_HINTER
psh_glyph_done( glyph );
#endif
return error;
}
|
DoS Exec Code Mem. Corr.
| 0
|
ps_hints_apply( PS_Hints ps_hints,
FT_Outline* outline,
PSH_Globals globals,
FT_Render_Mode hint_mode )
{
PSH_GlyphRec glyphrec;
PSH_Glyph glyph = &glyphrec;
FT_Error error;
#ifdef DEBUG_HINTER
FT_Memory memory;
#endif
FT_Int dimension;
/* something to do? */
if ( outline->n_points == 0 || outline->n_contours == 0 )
return PSH_Err_Ok;
#ifdef DEBUG_HINTER
memory = globals->memory;
if ( ps_debug_glyph )
{
psh_glyph_done( ps_debug_glyph );
FT_FREE( ps_debug_glyph );
}
if ( FT_NEW( glyph ) )
return error;
ps_debug_glyph = glyph;
#endif /* DEBUG_HINTER */
error = psh_glyph_init( glyph, outline, ps_hints, globals );
if ( error )
goto Exit;
/* try to optimize the y_scale so that the top of non-capital letters
* is aligned on a pixel boundary whenever possible
*/
{
PSH_Dimension dim_x = &glyph->globals->dimension[0];
PSH_Dimension dim_y = &glyph->globals->dimension[1];
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed old_x_scale = x_scale;
FT_Fixed old_y_scale = y_scale;
FT_Fixed scaled;
FT_Fixed fitted;
FT_Bool rescale = FALSE;
scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
fitted = FT_PIX_ROUND( scaled );
if ( fitted != 0 && scaled != fitted )
{
rescale = TRUE;
y_scale = FT_MulDiv( y_scale, fitted, scaled );
if ( fitted < scaled )
x_scale -= x_scale / 50;
psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
}
glyph->do_horz_hints = 1;
glyph->do_vert_hints = 1;
glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
psh_glyph_load_points( glyph, dimension );
/* compute local extrema */
psh_glyph_compute_extrema( glyph );
/* compute aligned stem/hints positions */
psh_hint_table_align_hints( &glyph->hint_tables[dimension],
glyph->globals,
dimension,
glyph );
/* find strong points, align them, then interpolate others */
psh_glyph_find_strong_points( glyph, dimension );
if ( dimension == 1 )
psh_glyph_find_blue_points( &globals->blues, glyph );
psh_glyph_interpolate_strong_points( glyph, dimension );
psh_glyph_interpolate_normal_points( glyph, dimension );
psh_glyph_interpolate_other_points( glyph, dimension );
/* save hinted coordinates back to outline */
psh_glyph_save_points( glyph, dimension );
if ( rescale )
psh_globals_set_scale( glyph->globals,
old_x_scale, old_y_scale, 0, 0 );
}
}
Exit:
#ifndef DEBUG_HINTER
psh_glyph_done( glyph );
#endif
return error;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,235
|
ps_simple_scale( PSH_Hint_Table table,
FT_Fixed scale,
FT_Fixed delta,
FT_Int dimension )
{
PSH_Hint hint;
FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
hint = table->hints + count;
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
if ( ps_debug_hint_func )
ps_debug_hint_func( hint, dimension );
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
ps_simple_scale( PSH_Hint_Table table,
FT_Fixed scale,
FT_Fixed delta,
FT_Int dimension )
{
PSH_Hint hint;
FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
hint = table->hints + count;
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
if ( ps_debug_hint_func )
ps_debug_hint_func( hint, dimension );
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,236
|
psh_compute_dir( FT_Pos dx,
FT_Pos dy )
{
FT_Pos ax, ay;
int result = PSH_DIR_NONE;
ax = ( dx >= 0 ) ? dx : -dx;
ay = ( dy >= 0 ) ? dy : -dy;
if ( ay * 12 < ax )
{
/* |dy| <<< |dx| means a near-horizontal segment */
result = ( dx >= 0 ) ? PSH_DIR_RIGHT : PSH_DIR_LEFT;
}
else if ( ax * 12 < ay )
{
/* |dx| <<< |dy| means a near-vertical segment */
result = ( dy >= 0 ) ? PSH_DIR_UP : PSH_DIR_DOWN;
}
return result;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_compute_dir( FT_Pos dx,
FT_Pos dy )
{
FT_Pos ax, ay;
int result = PSH_DIR_NONE;
ax = ( dx >= 0 ) ? dx : -dx;
ay = ( dy >= 0 ) ? dy : -dy;
if ( ay * 12 < ax )
{
/* |dy| <<< |dx| means a near-horizontal segment */
result = ( dx >= 0 ) ? PSH_DIR_RIGHT : PSH_DIR_LEFT;
}
else if ( ax * 12 < ay )
{
/* |dx| <<< |dy| means a near-vertical segment */
result = ( dy >= 0 ) ? PSH_DIR_UP : PSH_DIR_DOWN;
}
return result;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,237
|
psh_corner_is_flat( FT_Pos x_in,
FT_Pos y_in,
FT_Pos x_out,
FT_Pos y_out )
{
FT_Pos ax = x_in;
FT_Pos ay = y_in;
FT_Pos d_in, d_out, d_corner;
if ( ax < 0 )
ax = -ax;
if ( ay < 0 )
ay = -ay;
d_in = ax + ay;
ax = x_out;
if ( ax < 0 )
ax = -ax;
ay = y_out;
if ( ay < 0 )
ay = -ay;
d_out = ax + ay;
ax = x_out + x_in;
if ( ax < 0 )
ax = -ax;
ay = y_out + y_in;
if ( ay < 0 )
ay = -ay;
d_corner = ax + ay;
return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_corner_is_flat( FT_Pos x_in,
FT_Pos y_in,
FT_Pos x_out,
FT_Pos y_out )
{
FT_Pos ax = x_in;
FT_Pos ay = y_in;
FT_Pos d_in, d_out, d_corner;
if ( ax < 0 )
ax = -ax;
if ( ay < 0 )
ay = -ay;
d_in = ax + ay;
ax = x_out;
if ( ax < 0 )
ax = -ax;
ay = y_out;
if ( ay < 0 )
ay = -ay;
d_out = ax + ay;
ax = x_out + x_in;
if ( ax < 0 )
ax = -ax;
ay = y_out + y_in;
if ( ay < 0 )
ay = -ay;
d_corner = ax + ay;
return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,238
|
psh_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
FT_Int result;
/* deal with the trivial cases quickly */
if ( in_y == 0 )
{
if ( in_x >= 0 )
result = out_y;
else
result = -out_y;
}
else if ( in_x == 0 )
{
if ( in_y >= 0 )
result = -out_x;
else
result = out_x;
}
else if ( out_y == 0 )
{
if ( out_x >= 0 )
result = in_y;
else
result = -in_y;
}
else if ( out_x == 0 )
{
if ( out_y >= 0 )
result = -in_x;
else
result = in_x;
}
else /* general case */
{
long long delta = (long long)in_x * out_y - (long long)in_y * out_x;
if ( delta == 0 )
result = 0;
else
result = 1 - 2 * ( delta < 0 );
}
return result;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
FT_Int result;
/* deal with the trivial cases quickly */
if ( in_y == 0 )
{
if ( in_x >= 0 )
result = out_y;
else
result = -out_y;
}
else if ( in_x == 0 )
{
if ( in_y >= 0 )
result = -out_x;
else
result = out_x;
}
else if ( out_y == 0 )
{
if ( out_x >= 0 )
result = in_y;
else
result = -in_y;
}
else if ( out_x == 0 )
{
if ( out_y >= 0 )
result = -in_x;
else
result = in_x;
}
else /* general case */
{
long long delta = (long long)in_x * out_y - (long long)in_y * out_x;
if ( delta == 0 )
result = 0;
else
result = 1 - 2 * ( delta < 0 );
}
return result;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,239
|
psh_dimension_quantize_len( PSH_Dimension dim,
FT_Pos len,
FT_Bool do_snapping )
{
if ( len <= 64 )
len = 64;
else
{
FT_Pos delta = len - dim->stdw.widths[0].cur;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
len = dim->stdw.widths[0].cur;
if ( len < 48 )
len = 48;
}
if ( len < 3 * 64 )
{
delta = ( len & 63 );
len &= -64;
if ( delta < 10 )
len += delta;
else if ( delta < 32 )
len += 10;
else if ( delta < 54 )
len += 54;
else
len += delta;
}
else
len = FT_PIX_ROUND( len );
}
if ( do_snapping )
len = FT_PIX_ROUND( len );
return len;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_dimension_quantize_len( PSH_Dimension dim,
FT_Pos len,
FT_Bool do_snapping )
{
if ( len <= 64 )
len = 64;
else
{
FT_Pos delta = len - dim->stdw.widths[0].cur;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
len = dim->stdw.widths[0].cur;
if ( len < 48 )
len = 48;
}
if ( len < 3 * 64 )
{
delta = ( len & 63 );
len &= -64;
if ( delta < 10 )
len += delta;
else if ( delta < 32 )
len += 10;
else if ( delta < 54 )
len += 54;
else
len += delta;
}
else
len = FT_PIX_ROUND( len );
}
if ( do_snapping )
len = FT_PIX_ROUND( len );
return len;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,240
|
psh_glyph_compute_extrema( PSH_Glyph glyph )
{
FT_UInt n;
/* first of all, compute all local extrema */
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH_Point first = glyph->contours[n].start;
PSH_Point point, before, after;
if ( glyph->contours[n].count == 0 )
continue;
point = first;
before = point;
after = point;
do
{
before = before->prev;
if ( before == first )
goto Skip;
} while ( before->org_u == point->org_u );
first = point = before->next;
for (;;)
{
after = point;
do
{
after = after->next;
if ( after == first )
goto Next;
} while ( after->org_u == point->org_u );
if ( before->org_u < point->org_u )
{
if ( after->org_u < point->org_u )
{
/* local maximum */
goto Extremum;
}
}
else /* before->org_u > point->org_u */
{
if ( after->org_u > point->org_u )
{
/* local minimum */
Extremum:
do
{
psh_point_set_extremum( point );
point = point->next;
} while ( point != after );
}
}
before = after->prev;
point = after;
} /* for */
Next:
;
}
/* for each extremum, determine its direction along the */
/* orthogonal axis */
for ( n = 0; n < glyph->num_points; n++ )
{
PSH_Point point, before, after;
point = &glyph->points[n];
before = point;
after = point;
if ( psh_point_is_extremum( point ) )
{
do
{
before = before->prev;
if ( before == point )
goto Skip;
} while ( before->org_v == point->org_v );
do
{
after = after->next;
if ( after == point )
goto Skip;
} while ( after->org_v == point->org_v );
}
if ( before->org_v < point->org_v &&
after->org_v > point->org_v )
{
psh_point_set_positive( point );
}
else if ( before->org_v > point->org_v &&
after->org_v < point->org_v )
{
psh_point_set_negative( point );
}
Skip:
;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_compute_extrema( PSH_Glyph glyph )
{
FT_UInt n;
/* first of all, compute all local extrema */
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH_Point first = glyph->contours[n].start;
PSH_Point point, before, after;
if ( glyph->contours[n].count == 0 )
continue;
point = first;
before = point;
after = point;
do
{
before = before->prev;
if ( before == first )
goto Skip;
} while ( before->org_u == point->org_u );
first = point = before->next;
for (;;)
{
after = point;
do
{
after = after->next;
if ( after == first )
goto Next;
} while ( after->org_u == point->org_u );
if ( before->org_u < point->org_u )
{
if ( after->org_u < point->org_u )
{
/* local maximum */
goto Extremum;
}
}
else /* before->org_u > point->org_u */
{
if ( after->org_u > point->org_u )
{
/* local minimum */
Extremum:
do
{
psh_point_set_extremum( point );
point = point->next;
} while ( point != after );
}
}
before = after->prev;
point = after;
} /* for */
Next:
;
}
/* for each extremum, determine its direction along the */
/* orthogonal axis */
for ( n = 0; n < glyph->num_points; n++ )
{
PSH_Point point, before, after;
point = &glyph->points[n];
before = point;
after = point;
if ( psh_point_is_extremum( point ) )
{
do
{
before = before->prev;
if ( before == point )
goto Skip;
} while ( before->org_v == point->org_v );
do
{
after = after->next;
if ( after == point )
goto Skip;
} while ( after->org_v == point->org_v );
}
if ( before->org_v < point->org_v &&
after->org_v > point->org_v )
{
psh_point_set_positive( point );
}
else if ( before->org_v > point->org_v &&
after->org_v < point->org_v )
{
psh_point_set_negative( point );
}
Skip:
;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,241
|
psh_glyph_compute_inflections( PSH_Glyph glyph )
{
FT_UInt n;
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH_Point first, start, end, before, after;
FT_Pos in_x, in_y, out_x, out_y;
FT_Int orient_prev, orient_cur;
FT_Int finished = 0;
/* we need at least 4 points to create an inflection point */
if ( glyph->contours[n].count < 4 )
continue;
/* compute first segment in contour */
first = glyph->contours[n].start;
start = end = first;
do
{
end = end->next;
if ( end == first )
goto Skip;
in_x = end->org_u - start->org_u;
in_y = end->org_v - start->org_v;
} while ( in_x == 0 && in_y == 0 );
/* extend the segment start whenever possible */
before = start;
do
{
do
{
start = before;
before = before->prev;
if ( before == first )
goto Skip;
out_x = start->org_u - before->org_u;
out_y = start->org_v - before->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_prev == 0 );
first = start;
in_x = out_x;
in_y = out_y;
/* now, process all segments in the contour */
do
{
/* first, extend current segment's end whenever possible */
after = end;
do
{
do
{
end = after;
after = after->next;
if ( after == first )
finished = 1;
out_x = after->org_u - end->org_u;
out_y = after->org_v - end->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_cur == 0 );
if ( ( orient_cur ^ orient_prev ) < 0 )
{
do
{
psh_point_set_inflex( start );
start = start->next;
}
while ( start != end );
psh_point_set_inflex( start );
}
start = end;
end = after;
orient_prev = orient_cur;
in_x = out_x;
in_y = out_y;
} while ( !finished );
Skip:
;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_compute_inflections( PSH_Glyph glyph )
{
FT_UInt n;
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH_Point first, start, end, before, after;
FT_Pos in_x, in_y, out_x, out_y;
FT_Int orient_prev, orient_cur;
FT_Int finished = 0;
/* we need at least 4 points to create an inflection point */
if ( glyph->contours[n].count < 4 )
continue;
/* compute first segment in contour */
first = glyph->contours[n].start;
start = end = first;
do
{
end = end->next;
if ( end == first )
goto Skip;
in_x = end->org_u - start->org_u;
in_y = end->org_v - start->org_v;
} while ( in_x == 0 && in_y == 0 );
/* extend the segment start whenever possible */
before = start;
do
{
do
{
start = before;
before = before->prev;
if ( before == first )
goto Skip;
out_x = start->org_u - before->org_u;
out_y = start->org_v - before->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_prev == 0 );
first = start;
in_x = out_x;
in_y = out_y;
/* now, process all segments in the contour */
do
{
/* first, extend current segment's end whenever possible */
after = end;
do
{
do
{
end = after;
after = after->next;
if ( after == first )
finished = 1;
out_x = after->org_u - end->org_u;
out_y = after->org_v - end->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_cur == 0 );
if ( ( orient_cur ^ orient_prev ) < 0 )
{
do
{
psh_point_set_inflex( start );
start = start->next;
}
while ( start != end );
psh_point_set_inflex( start );
}
start = end;
end = after;
orient_prev = orient_cur;
in_x = out_x;
in_y = out_y;
} while ( !finished );
Skip:
;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,242
|
psh_glyph_done( PSH_Glyph glyph )
{
FT_Memory memory = glyph->memory;
psh_hint_table_done( &glyph->hint_tables[1], memory );
psh_hint_table_done( &glyph->hint_tables[0], memory );
FT_FREE( glyph->points );
FT_FREE( glyph->contours );
glyph->num_points = 0;
glyph->num_contours = 0;
glyph->memory = 0;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_done( PSH_Glyph glyph )
{
FT_Memory memory = glyph->memory;
psh_hint_table_done( &glyph->hint_tables[1], memory );
psh_hint_table_done( &glyph->hint_tables[0], memory );
FT_FREE( glyph->points );
FT_FREE( glyph->contours );
glyph->num_points = 0;
glyph->num_contours = 0;
glyph->memory = 0;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,243
|
psh_glyph_find_blue_points( PSH_Blues blues,
PSH_Glyph glyph )
{
PSH_Blue_Table table;
PSH_Blue_Zone zone;
FT_UInt glyph_count = glyph->num_points;
FT_UInt blue_count;
PSH_Point point = glyph->points;
for ( ; glyph_count > 0; glyph_count--, point++ )
{
FT_Pos y;
/* check tangents */
if ( !PSH_DIR_COMPARE( point->dir_in, PSH_DIR_HORIZONTAL ) &&
!PSH_DIR_COMPARE( point->dir_out, PSH_DIR_HORIZONTAL ) )
continue;
/* skip strong points */
if ( psh_point_is_strong( point ) )
continue;
y = point->org_u;
/* look up top zones */
table = &blues->normal_top;
blue_count = table->count;
zone = table->zones;
for ( ; blue_count > 0; blue_count--, zone++ )
{
FT_Pos delta = y - zone->org_bottom;
if ( delta < -blues->blue_fuzz )
break;
if ( y <= zone->org_top + blues->blue_fuzz )
if ( blues->no_overshoots || delta <= blues->blue_threshold )
{
point->cur_u = zone->cur_bottom;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
/* look up bottom zones */
table = &blues->normal_bottom;
blue_count = table->count;
zone = table->zones + blue_count - 1;
for ( ; blue_count > 0; blue_count--, zone-- )
{
FT_Pos delta = zone->org_top - y;
if ( delta < -blues->blue_fuzz )
break;
if ( y >= zone->org_bottom - blues->blue_fuzz )
if ( blues->no_overshoots || delta < blues->blue_threshold )
{
point->cur_u = zone->cur_top;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_find_blue_points( PSH_Blues blues,
PSH_Glyph glyph )
{
PSH_Blue_Table table;
PSH_Blue_Zone zone;
FT_UInt glyph_count = glyph->num_points;
FT_UInt blue_count;
PSH_Point point = glyph->points;
for ( ; glyph_count > 0; glyph_count--, point++ )
{
FT_Pos y;
/* check tangents */
if ( !PSH_DIR_COMPARE( point->dir_in, PSH_DIR_HORIZONTAL ) &&
!PSH_DIR_COMPARE( point->dir_out, PSH_DIR_HORIZONTAL ) )
continue;
/* skip strong points */
if ( psh_point_is_strong( point ) )
continue;
y = point->org_u;
/* look up top zones */
table = &blues->normal_top;
blue_count = table->count;
zone = table->zones;
for ( ; blue_count > 0; blue_count--, zone++ )
{
FT_Pos delta = y - zone->org_bottom;
if ( delta < -blues->blue_fuzz )
break;
if ( y <= zone->org_top + blues->blue_fuzz )
if ( blues->no_overshoots || delta <= blues->blue_threshold )
{
point->cur_u = zone->cur_bottom;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
/* look up bottom zones */
table = &blues->normal_bottom;
blue_count = table->count;
zone = table->zones + blue_count - 1;
for ( ; blue_count > 0; blue_count--, zone-- )
{
FT_Pos delta = zone->org_top - y;
if ( delta < -blues->blue_fuzz )
break;
if ( y >= zone->org_bottom - blues->blue_fuzz )
if ( blues->no_overshoots || delta < blues->blue_threshold )
{
point->cur_u = zone->cur_top;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,244
|
psh_glyph_init( PSH_Glyph glyph,
FT_Outline* outline,
PS_Hints ps_hints,
PSH_Globals globals )
{
FT_Error error;
FT_Memory memory;
/* clear all fields */
FT_MEM_ZERO( glyph, sizeof ( *glyph ) );
memory = glyph->memory = globals->memory;
/* allocate and setup points + contours arrays */
if ( FT_NEW_ARRAY( glyph->points, outline->n_points ) ||
FT_NEW_ARRAY( glyph->contours, outline->n_contours ) )
goto Exit;
glyph->num_points = outline->n_points;
glyph->num_contours = outline->n_contours;
{
FT_UInt first = 0, next, n;
PSH_Point points = glyph->points;
PSH_Contour contour = glyph->contours;
for ( n = 0; n < glyph->num_contours; n++ )
{
FT_Int count;
PSH_Point point;
next = outline->contours[n] + 1;
count = next - first;
contour->start = points + first;
contour->count = (FT_UInt)count;
if ( count > 0 )
{
point = points + first;
point->prev = points + next - 1;
point->contour = contour;
for ( ; count > 1; count-- )
{
point[0].next = point + 1;
point[1].prev = point;
point++;
point->contour = contour;
}
point->next = points + first;
}
contour++;
first = next;
}
}
{
PSH_Point points = glyph->points;
PSH_Point point = points;
FT_Vector* vec = outline->points;
FT_UInt n;
for ( n = 0; n < glyph->num_points; n++, point++ )
{
FT_Int n_prev = (FT_Int)( point->prev - points );
FT_Int n_next = (FT_Int)( point->next - points );
FT_Pos dxi, dyi, dxo, dyo;
if ( !( outline->tags[n] & FT_CURVE_TAG_ON ) )
point->flags = PSH_POINT_OFF;
dxi = vec[n].x - vec[n_prev].x;
dyi = vec[n].y - vec[n_prev].y;
point->dir_in = (FT_Char)psh_compute_dir( dxi, dyi );
dxo = vec[n_next].x - vec[n].x;
dyo = vec[n_next].y - vec[n].y;
point->dir_out = (FT_Char)psh_compute_dir( dxo, dyo );
/* detect smooth points */
if ( point->flags & PSH_POINT_OFF )
point->flags |= PSH_POINT_SMOOTH;
else if ( point->dir_in == point->dir_out )
{
if ( point->dir_out != PSH_DIR_NONE ||
psh_corner_is_flat( dxi, dyi, dxo, dyo ) )
point->flags |= PSH_POINT_SMOOTH;
}
}
}
glyph->outline = outline;
glyph->globals = globals;
#ifdef COMPUTE_INFLEXS
psh_glyph_load_points( glyph, 0 );
psh_glyph_compute_inflections( glyph );
#endif /* COMPUTE_INFLEXS */
/* now deal with hints tables */
error = psh_hint_table_init( &glyph->hint_tables [0],
&ps_hints->dimension[0].hints,
&ps_hints->dimension[0].masks,
&ps_hints->dimension[0].counters,
memory );
if ( error )
goto Exit;
error = psh_hint_table_init( &glyph->hint_tables [1],
&ps_hints->dimension[1].hints,
&ps_hints->dimension[1].masks,
&ps_hints->dimension[1].counters,
memory );
if ( error )
goto Exit;
Exit:
return error;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_init( PSH_Glyph glyph,
FT_Outline* outline,
PS_Hints ps_hints,
PSH_Globals globals )
{
FT_Error error;
FT_Memory memory;
/* clear all fields */
FT_MEM_ZERO( glyph, sizeof ( *glyph ) );
memory = glyph->memory = globals->memory;
/* allocate and setup points + contours arrays */
if ( FT_NEW_ARRAY( glyph->points, outline->n_points ) ||
FT_NEW_ARRAY( glyph->contours, outline->n_contours ) )
goto Exit;
glyph->num_points = outline->n_points;
glyph->num_contours = outline->n_contours;
{
FT_UInt first = 0, next, n;
PSH_Point points = glyph->points;
PSH_Contour contour = glyph->contours;
for ( n = 0; n < glyph->num_contours; n++ )
{
FT_Int count;
PSH_Point point;
next = outline->contours[n] + 1;
count = next - first;
contour->start = points + first;
contour->count = (FT_UInt)count;
if ( count > 0 )
{
point = points + first;
point->prev = points + next - 1;
point->contour = contour;
for ( ; count > 1; count-- )
{
point[0].next = point + 1;
point[1].prev = point;
point++;
point->contour = contour;
}
point->next = points + first;
}
contour++;
first = next;
}
}
{
PSH_Point points = glyph->points;
PSH_Point point = points;
FT_Vector* vec = outline->points;
FT_UInt n;
for ( n = 0; n < glyph->num_points; n++, point++ )
{
FT_Int n_prev = (FT_Int)( point->prev - points );
FT_Int n_next = (FT_Int)( point->next - points );
FT_Pos dxi, dyi, dxo, dyo;
if ( !( outline->tags[n] & FT_CURVE_TAG_ON ) )
point->flags = PSH_POINT_OFF;
dxi = vec[n].x - vec[n_prev].x;
dyi = vec[n].y - vec[n_prev].y;
point->dir_in = (FT_Char)psh_compute_dir( dxi, dyi );
dxo = vec[n_next].x - vec[n].x;
dyo = vec[n_next].y - vec[n].y;
point->dir_out = (FT_Char)psh_compute_dir( dxo, dyo );
/* detect smooth points */
if ( point->flags & PSH_POINT_OFF )
point->flags |= PSH_POINT_SMOOTH;
else if ( point->dir_in == point->dir_out )
{
if ( point->dir_out != PSH_DIR_NONE ||
psh_corner_is_flat( dxi, dyi, dxo, dyo ) )
point->flags |= PSH_POINT_SMOOTH;
}
}
}
glyph->outline = outline;
glyph->globals = globals;
#ifdef COMPUTE_INFLEXS
psh_glyph_load_points( glyph, 0 );
psh_glyph_compute_inflections( glyph );
#endif /* COMPUTE_INFLEXS */
/* now deal with hints tables */
error = psh_hint_table_init( &glyph->hint_tables [0],
&ps_hints->dimension[0].hints,
&ps_hints->dimension[0].masks,
&ps_hints->dimension[0].counters,
memory );
if ( error )
goto Exit;
error = psh_hint_table_init( &glyph->hint_tables [1],
&ps_hints->dimension[1].hints,
&ps_hints->dimension[1].masks,
&ps_hints->dimension[1].counters,
memory );
if ( error )
goto Exit;
Exit:
return error;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,245
|
psh_glyph_interpolate_normal_points( PSH_Glyph glyph,
FT_Int dimension )
{
#if 1
/* first technique: a point is strong if it is a local extremum */
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Memory memory = glyph->memory;
PSH_Point* strongs = NULL;
PSH_Point strongs_0[PSH_MAX_STRONG_INTERNAL];
FT_UInt num_strongs = 0;
PSH_Point points = glyph->points;
PSH_Point points_end = points + glyph->num_points;
PSH_Point point;
/* first count the number of strong points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
num_strongs++;
}
if ( num_strongs == 0 ) /* nothing to do here */
return;
/* allocate an array to store a list of points, */
/* stored in increasing org_u order */
if ( num_strongs <= PSH_MAX_STRONG_INTERNAL )
strongs = strongs_0;
else
{
FT_Error error;
if ( FT_NEW_ARRAY( strongs, num_strongs ) )
return;
}
num_strongs = 0;
for ( point = points; point < points_end; point++ )
{
PSH_Point* insert;
if ( !psh_point_is_strong( point ) )
continue;
for ( insert = strongs + num_strongs; insert > strongs; insert-- )
{
if ( insert[-1]->org_u <= point->org_u )
break;
insert[0] = insert[-1];
}
insert[0] = point;
num_strongs++;
}
/* now try to interpolate all normal points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
continue;
/* sometimes, some local extrema are smooth points */
if ( psh_point_is_smooth( point ) )
{
if ( point->dir_in == PSH_DIR_NONE ||
point->dir_in != point->dir_out )
continue;
if ( !psh_point_is_extremum( point ) &&
!psh_point_is_inflex( point ) )
continue;
point->flags &= ~PSH_POINT_SMOOTH;
}
/* find best enclosing point coordinates then interpolate */
{
PSH_Point before, after;
FT_UInt nn;
for ( nn = 0; nn < num_strongs; nn++ )
if ( strongs[nn]->org_u > point->org_u )
break;
if ( nn == 0 ) /* point before the first strong point */
{
after = strongs[0];
point->cur_u = after->cur_u +
FT_MulFix( point->org_u - after->org_u,
scale );
}
else
{
before = strongs[nn - 1];
for ( nn = num_strongs; nn > 0; nn-- )
if ( strongs[nn - 1]->org_u < point->org_u )
break;
if ( nn == num_strongs ) /* point is after last strong point */
{
before = strongs[nn - 1];
point->cur_u = before->cur_u +
FT_MulFix( point->org_u - before->org_u,
scale );
}
else
{
FT_Pos u;
after = strongs[nn];
/* now interpolate point between before and after */
u = point->org_u;
if ( u == before->org_u )
point->cur_u = before->cur_u;
else if ( u == after->org_u )
point->cur_u = after->cur_u;
else
point->cur_u = before->cur_u +
FT_MulDiv( u - before->org_u,
after->cur_u - before->cur_u,
after->org_u - before->org_u );
}
}
psh_point_set_fitted( point );
}
}
if ( strongs != strongs_0 )
FT_FREE( strongs );
#endif /* 1 */
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_interpolate_normal_points( PSH_Glyph glyph,
FT_Int dimension )
{
#if 1
/* first technique: a point is strong if it is a local extremum */
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Memory memory = glyph->memory;
PSH_Point* strongs = NULL;
PSH_Point strongs_0[PSH_MAX_STRONG_INTERNAL];
FT_UInt num_strongs = 0;
PSH_Point points = glyph->points;
PSH_Point points_end = points + glyph->num_points;
PSH_Point point;
/* first count the number of strong points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
num_strongs++;
}
if ( num_strongs == 0 ) /* nothing to do here */
return;
/* allocate an array to store a list of points, */
/* stored in increasing org_u order */
if ( num_strongs <= PSH_MAX_STRONG_INTERNAL )
strongs = strongs_0;
else
{
FT_Error error;
if ( FT_NEW_ARRAY( strongs, num_strongs ) )
return;
}
num_strongs = 0;
for ( point = points; point < points_end; point++ )
{
PSH_Point* insert;
if ( !psh_point_is_strong( point ) )
continue;
for ( insert = strongs + num_strongs; insert > strongs; insert-- )
{
if ( insert[-1]->org_u <= point->org_u )
break;
insert[0] = insert[-1];
}
insert[0] = point;
num_strongs++;
}
/* now try to interpolate all normal points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
continue;
/* sometimes, some local extrema are smooth points */
if ( psh_point_is_smooth( point ) )
{
if ( point->dir_in == PSH_DIR_NONE ||
point->dir_in != point->dir_out )
continue;
if ( !psh_point_is_extremum( point ) &&
!psh_point_is_inflex( point ) )
continue;
point->flags &= ~PSH_POINT_SMOOTH;
}
/* find best enclosing point coordinates then interpolate */
{
PSH_Point before, after;
FT_UInt nn;
for ( nn = 0; nn < num_strongs; nn++ )
if ( strongs[nn]->org_u > point->org_u )
break;
if ( nn == 0 ) /* point before the first strong point */
{
after = strongs[0];
point->cur_u = after->cur_u +
FT_MulFix( point->org_u - after->org_u,
scale );
}
else
{
before = strongs[nn - 1];
for ( nn = num_strongs; nn > 0; nn-- )
if ( strongs[nn - 1]->org_u < point->org_u )
break;
if ( nn == num_strongs ) /* point is after last strong point */
{
before = strongs[nn - 1];
point->cur_u = before->cur_u +
FT_MulFix( point->org_u - before->org_u,
scale );
}
else
{
FT_Pos u;
after = strongs[nn];
/* now interpolate point between before and after */
u = point->org_u;
if ( u == before->org_u )
point->cur_u = before->cur_u;
else if ( u == after->org_u )
point->cur_u = after->cur_u;
else
point->cur_u = before->cur_u +
FT_MulDiv( u - before->org_u,
after->cur_u - before->cur_u,
after->org_u - before->org_u );
}
}
psh_point_set_fitted( point );
}
}
if ( strongs != strongs_0 )
FT_FREE( strongs );
#endif /* 1 */
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,246
|
psh_glyph_interpolate_other_points( PSH_Glyph glyph,
FT_Int dimension )
{
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
PSH_Contour contour = glyph->contours;
FT_UInt num_contours = glyph->num_contours;
for ( ; num_contours > 0; num_contours--, contour++ )
{
PSH_Point start = contour->start;
PSH_Point first, next, point;
FT_UInt fit_count;
/* count the number of strong points in this contour */
next = start + contour->count;
fit_count = 0;
first = 0;
for ( point = start; point < next; point++ )
if ( psh_point_is_fitted( point ) )
{
if ( !first )
first = point;
fit_count++;
}
/* if there are less than 2 fitted points in the contour, we */
/* simply scale and eventually translate the contour points */
if ( fit_count < 2 )
{
if ( fit_count == 1 )
delta = first->cur_u - FT_MulFix( first->org_u, scale );
for ( point = start; point < next; point++ )
if ( point != first )
point->cur_u = FT_MulFix( point->org_u, scale ) + delta;
goto Next_Contour;
}
/* there are more than 2 strong points in this contour; we */
/* need to interpolate weak points between them */
start = first;
do
{
point = first;
/* skip consecutive fitted points */
for (;;)
{
next = first->next;
if ( next == start )
goto Next_Contour;
if ( !psh_point_is_fitted( next ) )
break;
first = next;
}
/* find next fitted point after unfitted one */
for (;;)
{
next = next->next;
if ( psh_point_is_fitted( next ) )
break;
}
/* now interpolate between them */
{
FT_Pos org_a, org_ab, cur_a, cur_ab;
FT_Pos org_c, org_ac, cur_c;
FT_Fixed scale_ab;
if ( first->org_u <= next->org_u )
{
org_a = first->org_u;
cur_a = first->cur_u;
org_ab = next->org_u - org_a;
cur_ab = next->cur_u - cur_a;
}
else
{
org_a = next->org_u;
cur_a = next->cur_u;
org_ab = first->org_u - org_a;
cur_ab = first->cur_u - cur_a;
}
scale_ab = 0x10000L;
if ( org_ab > 0 )
scale_ab = FT_DivFix( cur_ab, org_ab );
point = first->next;
do
{
org_c = point->org_u;
org_ac = org_c - org_a;
if ( org_ac <= 0 )
{
/* on the left of the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale );
}
else if ( org_ac >= org_ab )
{
/* on the right on the interpolation zone */
cur_c = cur_a + cur_ab + FT_MulFix( org_ac - org_ab, scale );
}
else
{
/* within the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale_ab );
}
point->cur_u = cur_c;
point = point->next;
} while ( point != next );
}
/* keep going until all points in the contours have been processed */
first = next;
} while ( first != start );
Next_Contour:
;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_interpolate_other_points( PSH_Glyph glyph,
FT_Int dimension )
{
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
PSH_Contour contour = glyph->contours;
FT_UInt num_contours = glyph->num_contours;
for ( ; num_contours > 0; num_contours--, contour++ )
{
PSH_Point start = contour->start;
PSH_Point first, next, point;
FT_UInt fit_count;
/* count the number of strong points in this contour */
next = start + contour->count;
fit_count = 0;
first = 0;
for ( point = start; point < next; point++ )
if ( psh_point_is_fitted( point ) )
{
if ( !first )
first = point;
fit_count++;
}
/* if there are less than 2 fitted points in the contour, we */
/* simply scale and eventually translate the contour points */
if ( fit_count < 2 )
{
if ( fit_count == 1 )
delta = first->cur_u - FT_MulFix( first->org_u, scale );
for ( point = start; point < next; point++ )
if ( point != first )
point->cur_u = FT_MulFix( point->org_u, scale ) + delta;
goto Next_Contour;
}
/* there are more than 2 strong points in this contour; we */
/* need to interpolate weak points between them */
start = first;
do
{
point = first;
/* skip consecutive fitted points */
for (;;)
{
next = first->next;
if ( next == start )
goto Next_Contour;
if ( !psh_point_is_fitted( next ) )
break;
first = next;
}
/* find next fitted point after unfitted one */
for (;;)
{
next = next->next;
if ( psh_point_is_fitted( next ) )
break;
}
/* now interpolate between them */
{
FT_Pos org_a, org_ab, cur_a, cur_ab;
FT_Pos org_c, org_ac, cur_c;
FT_Fixed scale_ab;
if ( first->org_u <= next->org_u )
{
org_a = first->org_u;
cur_a = first->cur_u;
org_ab = next->org_u - org_a;
cur_ab = next->cur_u - cur_a;
}
else
{
org_a = next->org_u;
cur_a = next->cur_u;
org_ab = first->org_u - org_a;
cur_ab = first->cur_u - cur_a;
}
scale_ab = 0x10000L;
if ( org_ab > 0 )
scale_ab = FT_DivFix( cur_ab, org_ab );
point = first->next;
do
{
org_c = point->org_u;
org_ac = org_c - org_a;
if ( org_ac <= 0 )
{
/* on the left of the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale );
}
else if ( org_ac >= org_ab )
{
/* on the right on the interpolation zone */
cur_c = cur_a + cur_ab + FT_MulFix( org_ac - org_ab, scale );
}
else
{
/* within the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale_ab );
}
point->cur_u = cur_c;
point = point->next;
} while ( point != next );
}
/* keep going until all points in the contours have been processed */
first = next;
} while ( first != start );
Next_Contour:
;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,247
|
psh_glyph_load_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_Vector* vec = glyph->outline->points;
PSH_Point point = glyph->points;
FT_UInt count = glyph->num_points;
for ( ; count > 0; count--, point++, vec++ )
{
point->flags2 = 0;
point->hint = NULL;
if ( dimension == 0 )
{
point->org_u = vec->x;
point->org_v = vec->y;
}
else
{
point->org_u = vec->y;
point->org_v = vec->x;
}
#ifdef DEBUG_HINTER
point->org_x = vec->x;
point->org_y = vec->y;
#endif
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_load_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_Vector* vec = glyph->outline->points;
PSH_Point point = glyph->points;
FT_UInt count = glyph->num_points;
for ( ; count > 0; count--, point++, vec++ )
{
point->flags2 = 0;
point->hint = NULL;
if ( dimension == 0 )
{
point->org_u = vec->x;
point->org_v = vec->y;
}
else
{
point->org_u = vec->y;
point->org_v = vec->x;
}
#ifdef DEBUG_HINTER
point->org_x = vec->x;
point->org_y = vec->y;
#endif
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,248
|
psh_glyph_save_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_UInt n;
PSH_Point point = glyph->points;
FT_Vector* vec = glyph->outline->points;
char* tags = glyph->outline->tags;
for ( n = 0; n < glyph->num_points; n++ )
{
if ( dimension == 0 )
vec[n].x = point->cur_u;
else
vec[n].y = point->cur_u;
if ( psh_point_is_strong( point ) )
tags[n] |= (char)( ( dimension == 0 ) ? 32 : 64 );
#ifdef DEBUG_HINTER
if ( dimension == 0 )
{
point->cur_x = point->cur_u;
point->flags_x = point->flags2 | point->flags;
}
else
{
point->cur_y = point->cur_u;
point->flags_y = point->flags2 | point->flags;
}
#endif
point++;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_glyph_save_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_UInt n;
PSH_Point point = glyph->points;
FT_Vector* vec = glyph->outline->points;
char* tags = glyph->outline->tags;
for ( n = 0; n < glyph->num_points; n++ )
{
if ( dimension == 0 )
vec[n].x = point->cur_u;
else
vec[n].y = point->cur_u;
if ( psh_point_is_strong( point ) )
tags[n] |= (char)( ( dimension == 0 ) ? 32 : 64 );
#ifdef DEBUG_HINTER
if ( dimension == 0 )
{
point->cur_x = point->cur_u;
point->flags_x = point->flags2 | point->flags;
}
else
{
point->cur_y = point->cur_u;
point->flags_y = point->flags2 | point->flags;
}
#endif
point++;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,249
|
psh_hint_align( PSH_Hint hint,
PSH_Globals globals,
FT_Int dimension,
PSH_Glyph glyph )
{
PSH_Dimension dim = &globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
if ( !psh_hint_is_fitted( hint ) )
{
FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
FT_Pos len = FT_MulFix( hint->org_len, scale );
FT_Int do_snapping;
FT_Pos fit_len;
PSH_AlignmentRec align;
/* ignore stem alignments when requested through the hint flags */
if ( ( dimension == 0 && !glyph->do_horz_hints ) ||
( dimension == 1 && !glyph->do_vert_hints ) )
{
hint->cur_pos = pos;
hint->cur_len = len;
psh_hint_set_fitted( hint );
return;
}
/* perform stem snapping when requested - this is necessary
* for monochrome and LCD hinting modes only
*/
do_snapping = ( dimension == 0 && glyph->do_horz_snapping ) ||
( dimension == 1 && glyph->do_vert_snapping );
hint->cur_len = fit_len = len;
/* check blue zones for horizontal stems */
align.align = PSH_BLUE_ALIGN_NONE;
align.align_bot = align.align_top = 0;
if ( dimension == 1 )
psh_blues_snap_stem( &globals->blues,
hint->org_pos + hint->org_len,
hint->org_pos,
&align );
switch ( align.align )
{
case PSH_BLUE_ALIGN_TOP:
/* the top of the stem is aligned against a blue zone */
hint->cur_pos = align.align_top - fit_len;
break;
case PSH_BLUE_ALIGN_BOT:
/* the bottom of the stem is aligned against a blue zone */
hint->cur_pos = align.align_bot;
break;
case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
/* both edges of the stem are aligned against blue zones */
hint->cur_pos = align.align_bot;
hint->cur_len = align.align_top - align.align_bot;
break;
default:
{
PSH_Hint parent = hint->parent;
if ( parent )
{
FT_Pos par_org_center, par_cur_center;
FT_Pos cur_org_center, cur_delta;
/* ensure that parent is already fitted */
if ( !psh_hint_is_fitted( parent ) )
psh_hint_align( parent, globals, dimension, glyph );
/* keep original relation between hints, this is, use the */
/* scaled distance between the centers of the hints to */
/* compute the new position */
par_org_center = parent->org_pos + ( parent->org_len >> 1 );
par_cur_center = parent->cur_pos + ( parent->cur_len >> 1 );
cur_org_center = hint->org_pos + ( hint->org_len >> 1 );
cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
pos = par_cur_center + cur_delta - ( len >> 1 );
}
hint->cur_pos = pos;
hint->cur_len = fit_len;
/* Stem adjustment tries to snap stem widths to standard
* ones. This is important to prevent unpleasant rounding
* artefacts.
*/
if ( glyph->do_stem_adjust )
{
if ( len <= 64 )
{
/* the stem is less than one pixel; we will center it
* around the nearest pixel center
*/
if ( len >= 32 )
{
/* This is a special case where we also widen the stem
* and align it to the pixel grid.
*
* stem_center = pos + (len/2)
* nearest_pixel_center = FT_ROUND(stem_center-32)+32
* new_pos = nearest_pixel_center-32
* = FT_ROUND(stem_center-32)
* = FT_FLOOR(stem_center-32+32)
* = FT_FLOOR(stem_center)
* new_len = 64
*/
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) );
len = 64;
}
else if ( len > 0 )
{
/* This is a very small stem; we simply align it to the
* pixel grid, trying to find the minimal displacement.
*
* left = pos
* right = pos + len
* left_nearest_edge = ROUND(pos)
* right_nearest_edge = ROUND(right)
*
* if ( ABS(left_nearest_edge - left) <=
* ABS(right_nearest_edge - right) )
* new_pos = left
* else
* new_pos = right
*/
FT_Pos left_nearest = FT_PIX_ROUND( pos );
FT_Pos right_nearest = FT_PIX_ROUND( pos + len );
FT_Pos left_disp = left_nearest - pos;
FT_Pos right_disp = right_nearest - ( pos + len );
if ( left_disp < 0 )
left_disp = -left_disp;
if ( right_disp < 0 )
right_disp = -right_disp;
if ( left_disp <= right_disp )
pos = left_nearest;
else
pos = right_nearest;
}
else
{
/* this is a ghost stem; we simply round it */
pos = FT_PIX_ROUND( pos );
}
}
else
{
len = psh_dimension_quantize_len( dim, len, 0 );
}
}
/* now that we have a good hinted stem width, try to position */
/* the stem along a pixel grid integer coordinate */
hint->cur_pos = pos + psh_hint_snap_stem_side_delta( pos, len );
hint->cur_len = len;
}
}
if ( do_snapping )
{
pos = hint->cur_pos;
len = hint->cur_len;
if ( len < 64 )
len = 64;
else
len = FT_PIX_ROUND( len );
switch ( align.align )
{
case PSH_BLUE_ALIGN_TOP:
hint->cur_pos = align.align_top - len;
hint->cur_len = len;
break;
case PSH_BLUE_ALIGN_BOT:
hint->cur_len = len;
break;
case PSH_BLUE_ALIGN_BOT | PSH_BLUE_ALIGN_TOP:
/* don't touch */
break;
default:
hint->cur_len = len;
if ( len & 64 )
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) ) + 32;
else
pos = FT_PIX_ROUND( pos + ( len >> 1 ) );
hint->cur_pos = pos - ( len >> 1 );
hint->cur_len = len;
}
}
psh_hint_set_fitted( hint );
#ifdef DEBUG_HINTER
if ( ps_debug_hint_func )
ps_debug_hint_func( hint, dimension );
#endif
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_align( PSH_Hint hint,
PSH_Globals globals,
FT_Int dimension,
PSH_Glyph glyph )
{
PSH_Dimension dim = &globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
if ( !psh_hint_is_fitted( hint ) )
{
FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
FT_Pos len = FT_MulFix( hint->org_len, scale );
FT_Int do_snapping;
FT_Pos fit_len;
PSH_AlignmentRec align;
/* ignore stem alignments when requested through the hint flags */
if ( ( dimension == 0 && !glyph->do_horz_hints ) ||
( dimension == 1 && !glyph->do_vert_hints ) )
{
hint->cur_pos = pos;
hint->cur_len = len;
psh_hint_set_fitted( hint );
return;
}
/* perform stem snapping when requested - this is necessary
* for monochrome and LCD hinting modes only
*/
do_snapping = ( dimension == 0 && glyph->do_horz_snapping ) ||
( dimension == 1 && glyph->do_vert_snapping );
hint->cur_len = fit_len = len;
/* check blue zones for horizontal stems */
align.align = PSH_BLUE_ALIGN_NONE;
align.align_bot = align.align_top = 0;
if ( dimension == 1 )
psh_blues_snap_stem( &globals->blues,
hint->org_pos + hint->org_len,
hint->org_pos,
&align );
switch ( align.align )
{
case PSH_BLUE_ALIGN_TOP:
/* the top of the stem is aligned against a blue zone */
hint->cur_pos = align.align_top - fit_len;
break;
case PSH_BLUE_ALIGN_BOT:
/* the bottom of the stem is aligned against a blue zone */
hint->cur_pos = align.align_bot;
break;
case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
/* both edges of the stem are aligned against blue zones */
hint->cur_pos = align.align_bot;
hint->cur_len = align.align_top - align.align_bot;
break;
default:
{
PSH_Hint parent = hint->parent;
if ( parent )
{
FT_Pos par_org_center, par_cur_center;
FT_Pos cur_org_center, cur_delta;
/* ensure that parent is already fitted */
if ( !psh_hint_is_fitted( parent ) )
psh_hint_align( parent, globals, dimension, glyph );
/* keep original relation between hints, this is, use the */
/* scaled distance between the centers of the hints to */
/* compute the new position */
par_org_center = parent->org_pos + ( parent->org_len >> 1 );
par_cur_center = parent->cur_pos + ( parent->cur_len >> 1 );
cur_org_center = hint->org_pos + ( hint->org_len >> 1 );
cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
pos = par_cur_center + cur_delta - ( len >> 1 );
}
hint->cur_pos = pos;
hint->cur_len = fit_len;
/* Stem adjustment tries to snap stem widths to standard
* ones. This is important to prevent unpleasant rounding
* artefacts.
*/
if ( glyph->do_stem_adjust )
{
if ( len <= 64 )
{
/* the stem is less than one pixel; we will center it
* around the nearest pixel center
*/
if ( len >= 32 )
{
/* This is a special case where we also widen the stem
* and align it to the pixel grid.
*
* stem_center = pos + (len/2)
* nearest_pixel_center = FT_ROUND(stem_center-32)+32
* new_pos = nearest_pixel_center-32
* = FT_ROUND(stem_center-32)
* = FT_FLOOR(stem_center-32+32)
* = FT_FLOOR(stem_center)
* new_len = 64
*/
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) );
len = 64;
}
else if ( len > 0 )
{
/* This is a very small stem; we simply align it to the
* pixel grid, trying to find the minimal displacement.
*
* left = pos
* right = pos + len
* left_nearest_edge = ROUND(pos)
* right_nearest_edge = ROUND(right)
*
* if ( ABS(left_nearest_edge - left) <=
* ABS(right_nearest_edge - right) )
* new_pos = left
* else
* new_pos = right
*/
FT_Pos left_nearest = FT_PIX_ROUND( pos );
FT_Pos right_nearest = FT_PIX_ROUND( pos + len );
FT_Pos left_disp = left_nearest - pos;
FT_Pos right_disp = right_nearest - ( pos + len );
if ( left_disp < 0 )
left_disp = -left_disp;
if ( right_disp < 0 )
right_disp = -right_disp;
if ( left_disp <= right_disp )
pos = left_nearest;
else
pos = right_nearest;
}
else
{
/* this is a ghost stem; we simply round it */
pos = FT_PIX_ROUND( pos );
}
}
else
{
len = psh_dimension_quantize_len( dim, len, 0 );
}
}
/* now that we have a good hinted stem width, try to position */
/* the stem along a pixel grid integer coordinate */
hint->cur_pos = pos + psh_hint_snap_stem_side_delta( pos, len );
hint->cur_len = len;
}
}
if ( do_snapping )
{
pos = hint->cur_pos;
len = hint->cur_len;
if ( len < 64 )
len = 64;
else
len = FT_PIX_ROUND( len );
switch ( align.align )
{
case PSH_BLUE_ALIGN_TOP:
hint->cur_pos = align.align_top - len;
hint->cur_len = len;
break;
case PSH_BLUE_ALIGN_BOT:
hint->cur_len = len;
break;
case PSH_BLUE_ALIGN_BOT | PSH_BLUE_ALIGN_TOP:
/* don't touch */
break;
default:
hint->cur_len = len;
if ( len & 64 )
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) ) + 32;
else
pos = FT_PIX_ROUND( pos + ( len >> 1 ) );
hint->cur_pos = pos - ( len >> 1 );
hint->cur_len = len;
}
}
psh_hint_set_fitted( hint );
#ifdef DEBUG_HINTER
if ( ps_debug_hint_func )
ps_debug_hint_func( hint, dimension );
#endif
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,250
|
psh_hint_overlap( PSH_Hint hint1,
PSH_Hint hint2 )
{
return hint1->org_pos + hint1->org_len >= hint2->org_pos &&
hint2->org_pos + hint2->org_len >= hint1->org_pos;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_overlap( PSH_Hint hint1,
PSH_Hint hint2 )
{
return hint1->org_pos + hint1->org_len >= hint2->org_pos &&
hint2->org_pos + hint2->org_len >= hint1->org_pos;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,251
|
psh_hint_snap_stem_side_delta( FT_Fixed pos,
FT_Fixed len )
{
FT_Fixed delta1 = FT_PIX_ROUND( pos ) - pos;
FT_Fixed delta2 = FT_PIX_ROUND( pos + len ) - pos - len;
if ( FT_ABS( delta1 ) <= FT_ABS( delta2 ) )
return delta1;
else
return delta2;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_snap_stem_side_delta( FT_Fixed pos,
FT_Fixed len )
{
FT_Fixed delta1 = FT_PIX_ROUND( pos ) - pos;
FT_Fixed delta2 = FT_PIX_ROUND( pos + len ) - pos - len;
if ( FT_ABS( delta1 ) <= FT_ABS( delta2 ) )
return delta1;
else
return delta2;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,252
|
psh_hint_table_activate_mask( PSH_Hint_Table table,
PS_Mask hint_mask )
{
FT_Int mask = 0, val = 0;
FT_Byte* cursor = hint_mask->bytes;
FT_UInt idx, limit, count;
limit = hint_mask->num_bits;
count = 0;
psh_hint_table_deactivate( table );
for ( idx = 0; idx < limit; idx++ )
{
if ( mask == 0 )
{
val = *cursor++;
mask = 0x80;
}
if ( val & mask )
{
PSH_Hint hint = &table->hints[idx];
if ( !psh_hint_is_active( hint ) )
{
FT_UInt count2;
#if 0
PSH_Hint* sort = table->sort;
PSH_Hint hint2;
for ( count2 = count; count2 > 0; count2--, sort++ )
{
hint2 = sort[0];
if ( psh_hint_overlap( hint, hint2 ) )
FT_TRACE0(( "psh_hint_table_activate_mask:"
" found overlapping hints\n" ))
}
#else
count2 = 0;
#endif
if ( count2 == 0 )
{
psh_hint_activate( hint );
if ( count < table->max_hints )
table->sort[count++] = hint;
else
FT_TRACE0(( "psh_hint_tableactivate_mask:"
" too many active hints\n" ));
}
}
}
mask >>= 1;
}
table->num_hints = count;
/* now, sort the hints; they are guaranteed to not overlap */
/* so we can compare their "org_pos" field directly */
{
FT_Int i1, i2;
PSH_Hint hint1, hint2;
PSH_Hint* sort = table->sort;
/* a simple bubble sort will do, since in 99% of cases, the hints */
/* will be already sorted -- and the sort will be linear */
for ( i1 = 1; i1 < (FT_Int)count; i1++ )
{
hint1 = sort[i1];
for ( i2 = i1 - 1; i2 >= 0; i2-- )
{
hint2 = sort[i2];
if ( hint2->org_pos < hint1->org_pos )
break;
sort[i2 + 1] = hint2;
sort[i2] = hint1;
}
}
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_activate_mask( PSH_Hint_Table table,
PS_Mask hint_mask )
{
FT_Int mask = 0, val = 0;
FT_Byte* cursor = hint_mask->bytes;
FT_UInt idx, limit, count;
limit = hint_mask->num_bits;
count = 0;
psh_hint_table_deactivate( table );
for ( idx = 0; idx < limit; idx++ )
{
if ( mask == 0 )
{
val = *cursor++;
mask = 0x80;
}
if ( val & mask )
{
PSH_Hint hint = &table->hints[idx];
if ( !psh_hint_is_active( hint ) )
{
FT_UInt count2;
#if 0
PSH_Hint* sort = table->sort;
PSH_Hint hint2;
for ( count2 = count; count2 > 0; count2--, sort++ )
{
hint2 = sort[0];
if ( psh_hint_overlap( hint, hint2 ) )
FT_TRACE0(( "psh_hint_table_activate_mask:"
" found overlapping hints\n" ))
}
#else
count2 = 0;
#endif
if ( count2 == 0 )
{
psh_hint_activate( hint );
if ( count < table->max_hints )
table->sort[count++] = hint;
else
FT_TRACE0(( "psh_hint_tableactivate_mask:"
" too many active hints\n" ));
}
}
}
mask >>= 1;
}
table->num_hints = count;
/* now, sort the hints; they are guaranteed to not overlap */
/* so we can compare their "org_pos" field directly */
{
FT_Int i1, i2;
PSH_Hint hint1, hint2;
PSH_Hint* sort = table->sort;
/* a simple bubble sort will do, since in 99% of cases, the hints */
/* will be already sorted -- and the sort will be linear */
for ( i1 = 1; i1 < (FT_Int)count; i1++ )
{
hint1 = sort[i1];
for ( i2 = i1 - 1; i2 >= 0; i2-- )
{
hint2 = sort[i2];
if ( hint2->org_pos < hint1->org_pos )
break;
sort[i2 + 1] = hint2;
sort[i2] = hint1;
}
}
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,253
|
psh_hint_table_align_hints( PSH_Hint_Table table,
PSH_Globals globals,
FT_Int dimension,
PSH_Glyph glyph )
{
PSH_Hint hint;
FT_UInt count;
#ifdef DEBUG_HINTER
PSH_Dimension dim = &globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
if ( ps_debug_no_vert_hints && dimension == 0 )
{
ps_simple_scale( table, scale, delta, dimension );
return;
}
if ( ps_debug_no_horz_hints && dimension == 1 )
{
ps_simple_scale( table, scale, delta, dimension );
return;
}
#endif /* DEBUG_HINTER*/
hint = table->hints;
count = table->max_hints;
for ( ; count > 0; count--, hint++ )
psh_hint_align( hint, globals, dimension, glyph );
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_align_hints( PSH_Hint_Table table,
PSH_Globals globals,
FT_Int dimension,
PSH_Glyph glyph )
{
PSH_Hint hint;
FT_UInt count;
#ifdef DEBUG_HINTER
PSH_Dimension dim = &globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
if ( ps_debug_no_vert_hints && dimension == 0 )
{
ps_simple_scale( table, scale, delta, dimension );
return;
}
if ( ps_debug_no_horz_hints && dimension == 1 )
{
ps_simple_scale( table, scale, delta, dimension );
return;
}
#endif /* DEBUG_HINTER*/
hint = table->hints;
count = table->max_hints;
for ( ; count > 0; count--, hint++ )
psh_hint_align( hint, globals, dimension, glyph );
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,254
|
psh_hint_table_deactivate( PSH_Hint_Table table )
{
FT_UInt count = table->max_hints;
PSH_Hint hint = table->hints;
for ( ; count > 0; count--, hint++ )
{
psh_hint_deactivate( hint );
hint->order = -1;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_deactivate( PSH_Hint_Table table )
{
FT_UInt count = table->max_hints;
PSH_Hint hint = table->hints;
for ( ; count > 0; count--, hint++ )
{
psh_hint_deactivate( hint );
hint->order = -1;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,255
|
psh_hint_table_done( PSH_Hint_Table table,
FT_Memory memory )
{
FT_FREE( table->zones );
table->num_zones = 0;
table->zone = 0;
FT_FREE( table->sort );
FT_FREE( table->hints );
table->num_hints = 0;
table->max_hints = 0;
table->sort_global = 0;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_done( PSH_Hint_Table table,
FT_Memory memory )
{
FT_FREE( table->zones );
table->num_zones = 0;
table->zone = 0;
FT_FREE( table->sort );
FT_FREE( table->hints );
table->num_hints = 0;
table->max_hints = 0;
table->sort_global = 0;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,256
|
psh_hint_table_find_strong_points( PSH_Hint_Table table,
PSH_Point point,
FT_UInt count,
FT_Int threshold,
FT_Int major_dir )
{
PSH_Hint* sort = table->sort;
FT_UInt num_hints = table->num_hints;
for ( ; count > 0; count--, point++ )
{
FT_Int point_dir = 0;
FT_Pos org_u = point->org_u;
if ( psh_point_is_strong( point ) )
continue;
if ( PSH_DIR_COMPARE( point->dir_in, major_dir ) )
point_dir = point->dir_in;
else if ( PSH_DIR_COMPARE( point->dir_out, major_dir ) )
point_dir = point->dir_out;
if ( point_dir )
{
if ( point_dir == major_dir )
{
FT_UInt nn;
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos;
if ( d < threshold && -d < threshold )
{
psh_point_set_strong( point );
point->flags2 |= PSH_POINT_EDGE_MIN;
point->hint = hint;
break;
}
}
}
else if ( point_dir == -major_dir )
{
FT_UInt nn;
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos - hint->org_len;
if ( d < threshold && -d < threshold )
{
psh_point_set_strong( point );
point->flags2 |= PSH_POINT_EDGE_MAX;
point->hint = hint;
break;
}
}
}
}
#if 1
else if ( psh_point_is_extremum( point ) )
{
/* treat extrema as special cases for stem edge alignment */
FT_UInt nn, min_flag, max_flag;
if ( major_dir == PSH_DIR_HORIZONTAL )
{
min_flag = PSH_POINT_POSITIVE;
max_flag = PSH_POINT_NEGATIVE;
}
else
{
min_flag = PSH_POINT_NEGATIVE;
max_flag = PSH_POINT_POSITIVE;
}
if ( point->flags2 & min_flag )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos;
if ( d < threshold && -d < threshold )
{
point->flags2 |= PSH_POINT_EDGE_MIN;
point->hint = hint;
psh_point_set_strong( point );
break;
}
}
}
else if ( point->flags2 & max_flag )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos - hint->org_len;
if ( d < threshold && -d < threshold )
{
point->flags2 |= PSH_POINT_EDGE_MAX;
point->hint = hint;
psh_point_set_strong( point );
break;
}
}
}
if ( point->hint == NULL )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
if ( org_u >= hint->org_pos &&
org_u <= hint->org_pos + hint->org_len )
{
point->hint = hint;
break;
}
}
}
}
#endif /* 1 */
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_find_strong_points( PSH_Hint_Table table,
PSH_Point point,
FT_UInt count,
FT_Int threshold,
FT_Int major_dir )
{
PSH_Hint* sort = table->sort;
FT_UInt num_hints = table->num_hints;
for ( ; count > 0; count--, point++ )
{
FT_Int point_dir = 0;
FT_Pos org_u = point->org_u;
if ( psh_point_is_strong( point ) )
continue;
if ( PSH_DIR_COMPARE( point->dir_in, major_dir ) )
point_dir = point->dir_in;
else if ( PSH_DIR_COMPARE( point->dir_out, major_dir ) )
point_dir = point->dir_out;
if ( point_dir )
{
if ( point_dir == major_dir )
{
FT_UInt nn;
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos;
if ( d < threshold && -d < threshold )
{
psh_point_set_strong( point );
point->flags2 |= PSH_POINT_EDGE_MIN;
point->hint = hint;
break;
}
}
}
else if ( point_dir == -major_dir )
{
FT_UInt nn;
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos - hint->org_len;
if ( d < threshold && -d < threshold )
{
psh_point_set_strong( point );
point->flags2 |= PSH_POINT_EDGE_MAX;
point->hint = hint;
break;
}
}
}
}
#if 1
else if ( psh_point_is_extremum( point ) )
{
/* treat extrema as special cases for stem edge alignment */
FT_UInt nn, min_flag, max_flag;
if ( major_dir == PSH_DIR_HORIZONTAL )
{
min_flag = PSH_POINT_POSITIVE;
max_flag = PSH_POINT_NEGATIVE;
}
else
{
min_flag = PSH_POINT_NEGATIVE;
max_flag = PSH_POINT_POSITIVE;
}
if ( point->flags2 & min_flag )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos;
if ( d < threshold && -d < threshold )
{
point->flags2 |= PSH_POINT_EDGE_MIN;
point->hint = hint;
psh_point_set_strong( point );
break;
}
}
}
else if ( point->flags2 & max_flag )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
FT_Pos d = org_u - hint->org_pos - hint->org_len;
if ( d < threshold && -d < threshold )
{
point->flags2 |= PSH_POINT_EDGE_MAX;
point->hint = hint;
psh_point_set_strong( point );
break;
}
}
}
if ( point->hint == NULL )
{
for ( nn = 0; nn < num_hints; nn++ )
{
PSH_Hint hint = sort[nn];
if ( org_u >= hint->org_pos &&
org_u <= hint->org_pos + hint->org_len )
{
point->hint = hint;
break;
}
}
}
}
#endif /* 1 */
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,257
|
psh_hint_table_init( PSH_Hint_Table table,
PS_Hint_Table hints,
PS_Mask_Table hint_masks,
PS_Mask_Table counter_masks,
FT_Memory memory )
{
FT_UInt count;
FT_Error error;
FT_UNUSED( counter_masks );
count = hints->num_hints;
/* allocate our tables */
if ( FT_NEW_ARRAY( table->sort, 2 * count ) ||
FT_NEW_ARRAY( table->hints, count ) ||
FT_NEW_ARRAY( table->zones, 2 * count + 1 ) )
goto Exit;
table->max_hints = count;
table->sort_global = table->sort + count;
table->num_hints = 0;
table->num_zones = 0;
table->zone = 0;
/* initialize the `table->hints' array */
{
PSH_Hint write = table->hints;
PS_Hint read = hints->hints;
for ( ; count > 0; count--, write++, read++ )
{
write->org_pos = read->pos;
write->org_len = read->len;
write->flags = read->flags;
}
}
/* we now need to determine the initial `parent' stems; first */
/* activate the hints that are given by the initial hint masks */
if ( hint_masks )
{
PS_Mask mask = hint_masks->masks;
count = hint_masks->num_masks;
table->hint_masks = hint_masks;
for ( ; count > 0; count--, mask++ )
psh_hint_table_record_mask( table, mask );
}
/* finally, do a linear parse in case some hints were left alone */
if ( table->num_hints != table->max_hints )
{
FT_UInt idx;
FT_TRACE0(( "psh_hint_table_init: missing/incorrect hint masks\n" ));
count = table->max_hints;
for ( idx = 0; idx < count; idx++ )
psh_hint_table_record( table, idx );
}
Exit:
return error;
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_init( PSH_Hint_Table table,
PS_Hint_Table hints,
PS_Mask_Table hint_masks,
PS_Mask_Table counter_masks,
FT_Memory memory )
{
FT_UInt count;
FT_Error error;
FT_UNUSED( counter_masks );
count = hints->num_hints;
/* allocate our tables */
if ( FT_NEW_ARRAY( table->sort, 2 * count ) ||
FT_NEW_ARRAY( table->hints, count ) ||
FT_NEW_ARRAY( table->zones, 2 * count + 1 ) )
goto Exit;
table->max_hints = count;
table->sort_global = table->sort + count;
table->num_hints = 0;
table->num_zones = 0;
table->zone = 0;
/* initialize the `table->hints' array */
{
PSH_Hint write = table->hints;
PS_Hint read = hints->hints;
for ( ; count > 0; count--, write++, read++ )
{
write->org_pos = read->pos;
write->org_len = read->len;
write->flags = read->flags;
}
}
/* we now need to determine the initial `parent' stems; first */
/* activate the hints that are given by the initial hint masks */
if ( hint_masks )
{
PS_Mask mask = hint_masks->masks;
count = hint_masks->num_masks;
table->hint_masks = hint_masks;
for ( ; count > 0; count--, mask++ )
psh_hint_table_record_mask( table, mask );
}
/* finally, do a linear parse in case some hints were left alone */
if ( table->num_hints != table->max_hints )
{
FT_UInt idx;
FT_TRACE0(( "psh_hint_table_init: missing/incorrect hint masks\n" ));
count = table->max_hints;
for ( idx = 0; idx < count; idx++ )
psh_hint_table_record( table, idx );
}
Exit:
return error;
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,258
|
psh_hint_table_record_mask( PSH_Hint_Table table,
PS_Mask hint_mask )
{
FT_Int mask = 0, val = 0;
FT_Byte* cursor = hint_mask->bytes;
FT_UInt idx, limit;
limit = hint_mask->num_bits;
for ( idx = 0; idx < limit; idx++ )
{
if ( mask == 0 )
{
val = *cursor++;
mask = 0x80;
}
if ( val & mask )
psh_hint_table_record( table, idx );
mask >>= 1;
}
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_hint_table_record_mask( PSH_Hint_Table table,
PS_Mask hint_mask )
{
FT_Int mask = 0, val = 0;
FT_Byte* cursor = hint_mask->bytes;
FT_UInt idx, limit;
limit = hint_mask->num_bits;
for ( idx = 0; idx < limit; idx++ )
{
if ( mask == 0 )
{
val = *cursor++;
mask = 0x80;
}
if ( val & mask )
psh_hint_table_record( table, idx );
mask >>= 1;
}
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,259
|
psh_print_zone( PSH_Zone zone )
{
printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n",
zone->scale / 65536.0,
zone->delta / 64.0,
zone->min,
zone->max );
}
|
DoS Exec Code Mem. Corr.
| 0
|
psh_print_zone( PSH_Zone zone )
{
printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n",
zone->scale / 65536.0,
zone->delta / 64.0,
zone->min,
zone->max );
}
|
@@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
+/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
- first = mask->end_point;
+ /* the `endchar' op can reduce the number of points */
+ first = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@@ -1698,7 +1702,9 @@
FT_Int count;
- next = mask->end_point;
+ next = mask->end_point > glyph->num_points
+ ? glyph->num_points
+ : mask->end_point;
count = next - first;
if ( count > 0 )
{
|
CWE-399
| null | null |
8,260
|
cff_builder_add_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Error error;
if ( !builder->load_points )
{
outline->n_contours++;
return CFF_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
outline->n_contours++;
}
return error;
}
|
DoS Exec Code
| 0
|
cff_builder_add_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Error error;
if ( !builder->load_points )
{
outline->n_contours++;
return CFF_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
outline->n_contours++;
}
return error;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,261
|
cff_builder_init( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting )
{
builder->path_begun = 0;
builder->load_points = 1;
builder->face = face;
builder->glyph = glyph;
builder->memory = face->root.memory;
if ( glyph )
{
FT_GlyphLoader loader = glyph->root.internal->loader;
builder->loader = loader;
builder->base = &loader->base.outline;
builder->current = &loader->current.outline;
FT_GlyphLoader_Rewind( loader );
builder->hints_globals = 0;
builder->hints_funcs = 0;
if ( hinting && size )
{
CFF_Internal internal = (CFF_Internal)size->root.internal;
builder->hints_globals = (void *)internal->topfont;
builder->hints_funcs = glyph->root.internal->glyph_hints;
}
}
builder->pos_x = 0;
builder->pos_y = 0;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
builder->advance.x = 0;
builder->advance.y = 0;
}
|
DoS Exec Code
| 0
|
cff_builder_init( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting )
{
builder->path_begun = 0;
builder->load_points = 1;
builder->face = face;
builder->glyph = glyph;
builder->memory = face->root.memory;
if ( glyph )
{
FT_GlyphLoader loader = glyph->root.internal->loader;
builder->loader = loader;
builder->base = &loader->base.outline;
builder->current = &loader->current.outline;
FT_GlyphLoader_Rewind( loader );
builder->hints_globals = 0;
builder->hints_funcs = 0;
if ( hinting && size )
{
CFF_Internal internal = (CFF_Internal)size->root.internal;
builder->hints_globals = (void *)internal->topfont;
builder->hints_funcs = glyph->root.internal->glyph_hints;
}
}
builder->pos_x = 0;
builder->pos_y = 0;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
builder->advance.x = 0;
builder->advance.y = 0;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,262
|
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error = CFF_Err_Ok;
/* test whether we are building a new contour */
if ( !builder->path_begun )
{
builder->path_begun = 1;
error = cff_builder_add_contour( builder );
if ( !error )
error = cff_builder_add_point1( builder, x, y );
}
return error;
}
|
DoS Exec Code
| 0
|
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error = CFF_Err_Ok;
/* test whether we are building a new contour */
if ( !builder->path_begun )
{
builder->path_begun = 1;
error = cff_builder_add_contour( builder );
if ( !error )
error = cff_builder_add_point1( builder, x, y );
}
return error;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,263
|
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode )
{
CFF_Font cff = (CFF_Font)face->extra.data;
/* clear everything */
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
/* initialize builder */
cff_builder_init( &decoder->builder, face, size, slot, hinting );
/* initialize Type2 decoder */
decoder->cff = cff;
decoder->num_globals = cff->global_subrs_index.count;
decoder->globals = cff->global_subrs;
decoder->globals_bias = cff_compute_bias(
cff->top_font.font_dict.charstring_type,
decoder->num_globals );
decoder->hint_mode = hint_mode;
}
|
DoS Exec Code
| 0
|
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode )
{
CFF_Font cff = (CFF_Font)face->extra.data;
/* clear everything */
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
/* initialize builder */
cff_builder_init( &decoder->builder, face, size, slot, hinting );
/* initialize Type2 decoder */
decoder->cff = cff;
decoder->num_globals = cff->global_subrs_index.count;
decoder->globals = cff->global_subrs;
decoder->globals_bias = cff_compute_bias(
cff->top_font.font_dict.charstring_type,
decoder->num_globals );
decoder->hint_mode = hint_mode;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,264
|
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index )
{
CFF_Builder *builder = &decoder->builder;
CFF_Font cff = (CFF_Font)builder->face->extra.data;
CFF_SubFont sub = &cff->top_font;
FT_Error error = CFF_Err_Ok;
/* manage CID fonts */
if ( cff->num_subfonts )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
if ( fd_index >= cff->num_subfonts )
{
FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
FT_TRACE4(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
sub = cff->subfonts[fd_index];
if ( builder->hints_funcs && size )
{
CFF_Internal internal = (CFF_Internal)size->root.internal;
/* for CFFs without subfonts, this value has already been set */
builder->hints_globals = (void *)internal->subfonts[fd_index];
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
else
FT_TRACE4(( "glyph index %d:\n", glyph_index ));
#endif
decoder->num_locals = sub->local_subrs_index.count;
decoder->locals = sub->local_subrs;
decoder->locals_bias = cff_compute_bias(
decoder->cff->top_font.font_dict.charstring_type,
decoder->num_locals );
decoder->glyph_width = sub->private_dict.default_width;
decoder->nominal_width = sub->private_dict.nominal_width;
Exit:
return error;
}
|
DoS Exec Code
| 0
|
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index )
{
CFF_Builder *builder = &decoder->builder;
CFF_Font cff = (CFF_Font)builder->face->extra.data;
CFF_SubFont sub = &cff->top_font;
FT_Error error = CFF_Err_Ok;
/* manage CID fonts */
if ( cff->num_subfonts )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
if ( fd_index >= cff->num_subfonts )
{
FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
FT_TRACE4(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
sub = cff->subfonts[fd_index];
if ( builder->hints_funcs && size )
{
CFF_Internal internal = (CFF_Internal)size->root.internal;
/* for CFFs without subfonts, this value has already been set */
builder->hints_globals = (void *)internal->subfonts[fd_index];
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
else
FT_TRACE4(( "glyph index %d:\n", glyph_index ));
#endif
decoder->num_locals = sub->local_subrs_index.count;
decoder->locals = sub->local_subrs;
decoder->locals_bias = cff_compute_bias(
decoder->cff->top_font.font_dict.charstring_type,
decoder->num_locals );
decoder->glyph_width = sub->private_dict.default_width;
decoder->nominal_width = sub->private_dict.nominal_width;
Exit:
return error;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,265
|
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
FT_ULong* length )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using the */
/* callback function. */
if ( face->root.internal->incremental_interface )
{
FT_Data data;
FT_Error error =
face->root.internal->incremental_interface->funcs->get_glyph_data(
face->root.internal->incremental_interface->object,
glyph_index, &data );
*pointer = (FT_Byte*)data.pointer;
*length = data.length;
return error;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
return cff_index_access_element( &cff->charstrings_index, glyph_index,
pointer, length );
}
}
|
DoS Exec Code
| 0
|
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
FT_ULong* length )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using the */
/* callback function. */
if ( face->root.internal->incremental_interface )
{
FT_Data data;
FT_Error error =
face->root.internal->incremental_interface->funcs->get_glyph_data(
face->root.internal->incremental_interface->object,
glyph_index, &data );
*pointer = (FT_Byte*)data.pointer;
*length = data.length;
return error;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
return cff_index_access_element( &cff->charstrings_index, glyph_index,
pointer, length );
}
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,266
|
cff_operator_seac( CFF_Decoder* decoder,
FT_Pos asb,
FT_Pos adx,
FT_Pos ady,
FT_Int bchar,
FT_Int achar )
{
FT_Error error;
CFF_Builder* builder = &decoder->builder;
FT_Int bchar_index, achar_index;
TT_Face face = decoder->builder.face;
FT_Vector left_bearing, advance;
FT_Byte* charstring;
FT_ULong charstring_len;
FT_Pos glyph_width;
if ( decoder->seac )
{
FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
return CFF_Err_Syntax_Error;
}
adx += decoder->builder.left_bearing.x;
ady += decoder->builder.left_bearing.y;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
if ( face->root.internal->incremental_interface )
{
bchar_index = bchar;
achar_index = achar;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
}
if ( bchar_index < 0 || achar_index < 0 )
{
FT_ERROR(( "cff_operator_seac:"
" invalid seac character code arguments\n" ));
return CFF_Err_Syntax_Error;
}
/* If we are trying to load a composite glyph, do not load the */
/* accent character and return the array of subglyphs. */
if ( builder->no_recurse )
{
FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
FT_GlyphLoader loader = glyph->internal->loader;
FT_SubGlyph subg;
/* reallocate subglyph array if necessary */
error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
if ( error )
goto Exit;
subg = loader->current.subglyphs;
/* subglyph 0 = base character */
subg->index = bchar_index;
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
FT_SUBGLYPH_FLAG_USE_MY_METRICS;
subg->arg1 = 0;
subg->arg2 = 0;
subg++;
/* subglyph 1 = accent character */
subg->index = achar_index;
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
subg->arg1 = (FT_Int)( adx >> 16 );
subg->arg2 = (FT_Int)( ady >> 16 );
/* set up remaining glyph fields */
glyph->num_subglyphs = 2;
glyph->subglyphs = loader->base.subglyphs;
glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
loader->current.num_subglyphs = 2;
}
FT_GlyphLoader_Prepare( builder->loader );
/* First load `bchar' in builder */
error = cff_get_glyph_data( face, bchar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
decoder->seac = FALSE;
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Save the left bearing, advance and glyph width of the base */
/* character as they will be erased by the next load. */
left_bearing = builder->left_bearing;
advance = builder->advance;
glyph_width = decoder->glyph_width;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
builder->pos_x = adx - asb;
builder->pos_y = ady;
/* Now load `achar' on top of the base outline. */
error = cff_get_glyph_data( face, achar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
decoder->seac = FALSE;
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Restore the left side bearing, advance and glyph width */
/* of the base character. */
builder->left_bearing = left_bearing;
builder->advance = advance;
decoder->glyph_width = glyph_width;
builder->pos_x = 0;
builder->pos_y = 0;
Exit:
return error;
}
|
DoS Exec Code
| 0
|
cff_operator_seac( CFF_Decoder* decoder,
FT_Pos asb,
FT_Pos adx,
FT_Pos ady,
FT_Int bchar,
FT_Int achar )
{
FT_Error error;
CFF_Builder* builder = &decoder->builder;
FT_Int bchar_index, achar_index;
TT_Face face = decoder->builder.face;
FT_Vector left_bearing, advance;
FT_Byte* charstring;
FT_ULong charstring_len;
FT_Pos glyph_width;
if ( decoder->seac )
{
FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
return CFF_Err_Syntax_Error;
}
adx += decoder->builder.left_bearing.x;
ady += decoder->builder.left_bearing.y;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
if ( face->root.internal->incremental_interface )
{
bchar_index = bchar;
achar_index = achar;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
}
if ( bchar_index < 0 || achar_index < 0 )
{
FT_ERROR(( "cff_operator_seac:"
" invalid seac character code arguments\n" ));
return CFF_Err_Syntax_Error;
}
/* If we are trying to load a composite glyph, do not load the */
/* accent character and return the array of subglyphs. */
if ( builder->no_recurse )
{
FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
FT_GlyphLoader loader = glyph->internal->loader;
FT_SubGlyph subg;
/* reallocate subglyph array if necessary */
error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
if ( error )
goto Exit;
subg = loader->current.subglyphs;
/* subglyph 0 = base character */
subg->index = bchar_index;
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
FT_SUBGLYPH_FLAG_USE_MY_METRICS;
subg->arg1 = 0;
subg->arg2 = 0;
subg++;
/* subglyph 1 = accent character */
subg->index = achar_index;
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
subg->arg1 = (FT_Int)( adx >> 16 );
subg->arg2 = (FT_Int)( ady >> 16 );
/* set up remaining glyph fields */
glyph->num_subglyphs = 2;
glyph->subglyphs = loader->base.subglyphs;
glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
loader->current.num_subglyphs = 2;
}
FT_GlyphLoader_Prepare( builder->loader );
/* First load `bchar' in builder */
error = cff_get_glyph_data( face, bchar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
decoder->seac = FALSE;
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Save the left bearing, advance and glyph width of the base */
/* character as they will be erased by the next load. */
left_bearing = builder->left_bearing;
advance = builder->advance;
glyph_width = decoder->glyph_width;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
builder->pos_x = adx - asb;
builder->pos_y = ady;
/* Now load `achar' on top of the base outline. */
error = cff_get_glyph_data( face, achar_index,
&charstring, &charstring_len );
if ( !error )
{
/* the seac operator must not be nested */
decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
decoder->seac = FALSE;
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Restore the left side bearing, advance and glyph width */
/* of the base character. */
builder->left_bearing = left_bearing;
builder->advance = advance;
decoder->glyph_width = glyph_width;
builder->pos_x = 0;
builder->pos_y = 0;
Exit:
return error;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,267
|
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
CFF_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Matrix font_matrix;
FT_Vector font_offset;
force_scaling = FALSE;
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
/* it immediately to the real glyph_index -- if it isn't a */
/* subsetted font, glyph_indices and CIDs are identical, though */
if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
cff->charset.cids )
{
/* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
if ( glyph_index != 0 )
{
glyph_index = cff_charset_cid_to_gindex( &cff->charset,
glyph_index );
if ( glyph_index == 0 )
return CFF_Err_Invalid_Argument;
}
}
else if ( glyph_index >= cff->num_glyphs )
return CFF_Err_Invalid_Argument;
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
glyph->x_scale = 0x10000L;
glyph->y_scale = 0x10000L;
if ( size )
{
glyph->x_scale = size->root.metrics.x_scale;
glyph->y_scale = size->root.metrics.y_scale;
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* try to load embedded bitmap if any */
/* */
/* XXX: The convention should be emphasized in */
/* the documents because it can be confusing. */
if ( size )
{
CFF_Face cff_face = (CFF_Face)size->root.face;
SFNT_Service sfnt = (SFNT_Service)cff_face->sfnt;
FT_Stream stream = cff_face->root.stream;
if ( size->strike_index != 0xFFFFFFFFUL &&
sfnt->load_eblc &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
TT_SBit_MetricsRec metrics;
error = sfnt->load_sbit_image( face,
size->strike_index,
glyph_index,
(FT_Int)load_flags,
stream,
&glyph->root.bitmap,
&metrics );
if ( !error )
{
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
glyph->root.metrics.width = (FT_Pos)metrics.width << 6;
glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
glyph->root.bitmap_left = metrics.vertBearingX;
glyph->root.bitmap_top = metrics.vertBearingY;
}
else
{
glyph->root.bitmap_left = metrics.horiBearingX;
glyph->root.bitmap_top = metrics.horiBearingY;
}
return error;
}
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* return immediately if we only want the embedded bitmaps */
if ( load_flags & FT_LOAD_SBITS_ONLY )
return CFF_Err_Invalid_Argument;
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */
/* this scaling is only relevant if the PS hinter isn't active */
if ( cff->num_subfonts )
{
FT_ULong top_upm, sub_upm;
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
if ( fd_index >= cff->num_subfonts )
fd_index = cff->num_subfonts - 1;
top_upm = cff->top_font.font_dict.units_per_em;
sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
if ( top_upm != sub_upm )
{
glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
force_scaling = TRUE;
}
}
else
{
font_matrix = cff->top_font.font_dict.font_matrix;
font_offset = cff->top_font.font_dict.font_offset;
}
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
{
FT_Byte* charstring;
FT_ULong charstring_len;
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
decoder.width_only = TRUE;
decoder.builder.no_recurse =
(FT_Bool)( load_flags & FT_LOAD_NO_RECURSE );
/* now load the unscaled outline */
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( !error )
{
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
cff_free_glyph_data( face, &charstring, charstring_len );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Control data and length may not be available for incremental */
/* fonts. */
if ( face->root.internal->incremental_interface )
{
glyph->root.control_data = 0;
glyph->root.control_len = 0;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/* We set control_data and control_len if charstrings is loaded. */
/* See how charstring loads at cff_index_access_element() in */
/* cffload.c. */
{
CFF_Index csindex = &cff->charstrings_index;
if ( csindex->offsets )
{
glyph->root.control_data = csindex->bytes +
csindex->offsets[glyph_index] - 1;
glyph->root.control_len = charstring_len;
}
}
}
}
/* save new glyph tables */
cff_builder_done( &decoder.builder );
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
if ( !error &&
face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
FT_Incremental_MetricsRec metrics;
metrics.bearing_x = decoder.builder.left_bearing.x;
metrics.bearing_y = 0;
metrics.advance = decoder.builder.advance.x;
metrics.advance_v = decoder.builder.advance.y;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
glyph_index, FALSE, &metrics );
decoder.builder.left_bearing.x = metrics.bearing_x;
decoder.builder.advance.x = metrics.advance;
decoder.builder.advance.y = metrics.advance_v;
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
if ( !error )
{
/* Now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax. */
/* For composite glyphs, return only left side bearing and */
/* advance width. */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = glyph->root.internal;
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
glyph->root.metrics.horiAdvance = decoder.glyph_width;
internal->glyph_matrix = font_matrix;
internal->glyph_delta = font_offset;
internal->glyph_transformed = 1;
}
else
{
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
FT_Vector advance;
FT_Bool has_vertical_info;
/* copy the _unscaled_ advance width */
metrics->horiAdvance = decoder.glyph_width;
glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0;
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 &&
face->vertical.long_metrics );
#else
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 );
#endif
/* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info )
{
FT_Short vertBearingY = 0;
FT_UShort vertAdvance = 0;
( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
glyph_index,
&vertBearingY,
&vertAdvance );
metrics->vertBearingY = vertBearingY;
metrics->vertAdvance = vertAdvance;
}
else
{
/* make up vertical ones */
if ( face->os2.version != 0xFFFFU )
metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
face->os2.sTypoDescender );
else
metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
face->horizontal.Descender );
}
glyph->root.linearVertAdvance = metrics->vertAdvance;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = 0;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
if ( !( font_matrix.xx == 0x10000L &&
font_matrix.yy == 0x10000L &&
font_matrix.xy == 0 &&
font_matrix.yx == 0 ) )
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
if ( !( font_offset.x == 0 &&
font_offset.y == 0 ) )
FT_Outline_Translate( &glyph->root.outline,
font_offset.x, font_offset.y );
advance.x = metrics->horiAdvance;
advance.y = 0;
FT_Vector_Transform( &advance, &font_matrix );
metrics->horiAdvance = advance.x + font_offset.x;
advance.x = 0;
advance.y = metrics->vertAdvance;
FT_Vector_Transform( &advance, &font_matrix );
metrics->vertAdvance = advance.y + font_offset.y;
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;
FT_Outline* cur = &glyph->root.outline;
FT_Vector* vec = cur->points;
FT_Fixed x_scale = glyph->x_scale;
FT_Fixed y_scale = glyph->y_scale;
/* First of all, scale the points */
if ( !hinting || !decoder.builder.hints_funcs )
for ( n = cur->n_points; n > 0; n--, vec++ )
{
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
}
/* Then scale the metrics */
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
}
/* compute the other metrics */
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
if ( has_vertical_info )
metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
else
{
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance );
}
}
}
return error;
}
|
DoS Exec Code
| 0
|
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
CFF_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Matrix font_matrix;
FT_Vector font_offset;
force_scaling = FALSE;
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
/* it immediately to the real glyph_index -- if it isn't a */
/* subsetted font, glyph_indices and CIDs are identical, though */
if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
cff->charset.cids )
{
/* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
if ( glyph_index != 0 )
{
glyph_index = cff_charset_cid_to_gindex( &cff->charset,
glyph_index );
if ( glyph_index == 0 )
return CFF_Err_Invalid_Argument;
}
}
else if ( glyph_index >= cff->num_glyphs )
return CFF_Err_Invalid_Argument;
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
glyph->x_scale = 0x10000L;
glyph->y_scale = 0x10000L;
if ( size )
{
glyph->x_scale = size->root.metrics.x_scale;
glyph->y_scale = size->root.metrics.y_scale;
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* try to load embedded bitmap if any */
/* */
/* XXX: The convention should be emphasized in */
/* the documents because it can be confusing. */
if ( size )
{
CFF_Face cff_face = (CFF_Face)size->root.face;
SFNT_Service sfnt = (SFNT_Service)cff_face->sfnt;
FT_Stream stream = cff_face->root.stream;
if ( size->strike_index != 0xFFFFFFFFUL &&
sfnt->load_eblc &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
TT_SBit_MetricsRec metrics;
error = sfnt->load_sbit_image( face,
size->strike_index,
glyph_index,
(FT_Int)load_flags,
stream,
&glyph->root.bitmap,
&metrics );
if ( !error )
{
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
glyph->root.metrics.width = (FT_Pos)metrics.width << 6;
glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
glyph->root.bitmap_left = metrics.vertBearingX;
glyph->root.bitmap_top = metrics.vertBearingY;
}
else
{
glyph->root.bitmap_left = metrics.horiBearingX;
glyph->root.bitmap_top = metrics.horiBearingY;
}
return error;
}
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* return immediately if we only want the embedded bitmaps */
if ( load_flags & FT_LOAD_SBITS_ONLY )
return CFF_Err_Invalid_Argument;
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */
/* this scaling is only relevant if the PS hinter isn't active */
if ( cff->num_subfonts )
{
FT_ULong top_upm, sub_upm;
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
if ( fd_index >= cff->num_subfonts )
fd_index = cff->num_subfonts - 1;
top_upm = cff->top_font.font_dict.units_per_em;
sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
if ( top_upm != sub_upm )
{
glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
force_scaling = TRUE;
}
}
else
{
font_matrix = cff->top_font.font_dict.font_matrix;
font_offset = cff->top_font.font_dict.font_offset;
}
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
{
FT_Byte* charstring;
FT_ULong charstring_len;
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
decoder.width_only = TRUE;
decoder.builder.no_recurse =
(FT_Bool)( load_flags & FT_LOAD_NO_RECURSE );
/* now load the unscaled outline */
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( !error )
{
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
cff_free_glyph_data( face, &charstring, charstring_len );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Control data and length may not be available for incremental */
/* fonts. */
if ( face->root.internal->incremental_interface )
{
glyph->root.control_data = 0;
glyph->root.control_len = 0;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/* We set control_data and control_len if charstrings is loaded. */
/* See how charstring loads at cff_index_access_element() in */
/* cffload.c. */
{
CFF_Index csindex = &cff->charstrings_index;
if ( csindex->offsets )
{
glyph->root.control_data = csindex->bytes +
csindex->offsets[glyph_index] - 1;
glyph->root.control_len = charstring_len;
}
}
}
}
/* save new glyph tables */
cff_builder_done( &decoder.builder );
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
if ( !error &&
face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
FT_Incremental_MetricsRec metrics;
metrics.bearing_x = decoder.builder.left_bearing.x;
metrics.bearing_y = 0;
metrics.advance = decoder.builder.advance.x;
metrics.advance_v = decoder.builder.advance.y;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
glyph_index, FALSE, &metrics );
decoder.builder.left_bearing.x = metrics.bearing_x;
decoder.builder.advance.x = metrics.advance;
decoder.builder.advance.y = metrics.advance_v;
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
if ( !error )
{
/* Now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax. */
/* For composite glyphs, return only left side bearing and */
/* advance width. */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = glyph->root.internal;
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
glyph->root.metrics.horiAdvance = decoder.glyph_width;
internal->glyph_matrix = font_matrix;
internal->glyph_delta = font_offset;
internal->glyph_transformed = 1;
}
else
{
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
FT_Vector advance;
FT_Bool has_vertical_info;
/* copy the _unscaled_ advance width */
metrics->horiAdvance = decoder.glyph_width;
glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0;
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 &&
face->vertical.long_metrics );
#else
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 );
#endif
/* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info )
{
FT_Short vertBearingY = 0;
FT_UShort vertAdvance = 0;
( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
glyph_index,
&vertBearingY,
&vertAdvance );
metrics->vertBearingY = vertBearingY;
metrics->vertAdvance = vertAdvance;
}
else
{
/* make up vertical ones */
if ( face->os2.version != 0xFFFFU )
metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
face->os2.sTypoDescender );
else
metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
face->horizontal.Descender );
}
glyph->root.linearVertAdvance = metrics->vertAdvance;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = 0;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
if ( !( font_matrix.xx == 0x10000L &&
font_matrix.yy == 0x10000L &&
font_matrix.xy == 0 &&
font_matrix.yx == 0 ) )
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
if ( !( font_offset.x == 0 &&
font_offset.y == 0 ) )
FT_Outline_Translate( &glyph->root.outline,
font_offset.x, font_offset.y );
advance.x = metrics->horiAdvance;
advance.y = 0;
FT_Vector_Transform( &advance, &font_matrix );
metrics->horiAdvance = advance.x + font_offset.x;
advance.x = 0;
advance.y = metrics->vertAdvance;
FT_Vector_Transform( &advance, &font_matrix );
metrics->vertAdvance = advance.y + font_offset.y;
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;
FT_Outline* cur = &glyph->root.outline;
FT_Vector* vec = cur->points;
FT_Fixed x_scale = glyph->x_scale;
FT_Fixed y_scale = glyph->y_scale;
/* First of all, scale the points */
if ( !hinting || !decoder.builder.hints_funcs )
for ( n = cur->n_points; n > 0; n--, vec++ )
{
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
}
/* Then scale the metrics */
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
}
/* compute the other metrics */
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
if ( has_vertical_info )
metrics->vertBearingX = metrics->horiBearingX -
metrics->horiAdvance / 2;
else
{
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance );
}
}
}
return error;
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,268
|
check_points( CFF_Builder* builder,
FT_Int count )
{
return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
|
DoS Exec Code
| 0
|
check_points( CFF_Builder* builder,
FT_Int count )
{
return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
|
@@ -2275,6 +2275,8 @@
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
break;
case cff_op_pop:
|
CWE-189
| null | null |
8,269
|
XvQueryExtension(
Display *dpy,
unsigned int *p_version,
unsigned int *p_revision,
unsigned int *p_requestBase,
unsigned int *p_eventBase,
unsigned int *p_errorBase)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryExtensionReq *req;
xvQueryExtensionReply rep;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
LockDisplay(dpy);
XvGetReq(QueryExtension, req);
if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
status = XvBadExtension;
goto out;
}
*p_version = rep.version;
*p_revision = rep.revision;
*p_requestBase = info->codes->major_opcode;
*p_eventBase = info->codes->first_event;
*p_errorBase = info->codes->first_error;
status = Success;
out:
UnlockDisplay(dpy);
SyncHandle();
return status;
}
| null | 0
|
XvQueryExtension(
Display *dpy,
unsigned int *p_version,
unsigned int *p_revision,
unsigned int *p_requestBase,
unsigned int *p_eventBase,
unsigned int *p_errorBase)
{
XExtDisplayInfo *info = xv_find_display(dpy);
xvQueryExtensionReq *req;
xvQueryExtensionReply rep;
int status;
XvCheckExtension(dpy, info, XvBadExtension);
LockDisplay(dpy);
XvGetReq(QueryExtension, req);
if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
status = XvBadExtension;
goto out;
}
*p_version = rep.version;
*p_revision = rep.revision;
*p_requestBase = info->codes->major_opcode;
*p_eventBase = info->codes->first_event;
*p_errorBase = info->codes->first_error;
status = Success;
out:
UnlockDisplay(dpy);
SyncHandle();
return status;
}
|
@@ -158,6 +158,7 @@ XvQueryAdaptors(
size_t size;
unsigned int ii, jj;
char *name;
+ char *end;
XvAdaptorInfo *pas = NULL, *pa;
XvFormat *pfs, *pf;
char *buffer = NULL;
@@ -197,17 +198,13 @@ XvQueryAdaptors(
/* GET INPUT ADAPTORS */
if (rep.num_adaptors == 0) {
- /* If there's no adaptors, there's nothing more to do. */
+ /* If there are no adaptors, there's nothing more to do. */
status = Success;
goto out;
}
- if (size < (rep.num_adaptors * sz_xvAdaptorInfo)) {
- /* If there's not enough data for the number of adaptors,
- then we have a problem. */
- status = XvBadReply;
- goto out;
- }
+ u.buffer = buffer;
+ end = buffer + size;
size = rep.num_adaptors * sizeof(XvAdaptorInfo);
if ((pas = Xmalloc(size)) == NULL) {
@@ -225,9 +222,12 @@ XvQueryAdaptors(
pa++;
}
- u.buffer = buffer;
pa = pas;
for (ii = 0; ii < rep.num_adaptors; ii++) {
+ if (u.buffer + sz_xvAdaptorInfo > end) {
+ status = XvBadReply;
+ goto out;
+ }
pa->type = u.pa->type;
pa->base_id = u.pa->base_id;
pa->num_ports = u.pa->num_ports;
@@ -239,6 +239,10 @@ XvQueryAdaptors(
size = u.pa->name_size;
u.buffer += pad_to_int32(sz_xvAdaptorInfo);
+ if (u.buffer + size > end) {
+ status = XvBadReply;
+ goto out;
+ }
if ((name = Xmalloc(size + 1)) == NULL) {
status = XvBadAlloc;
goto out;
@@ -259,6 +263,11 @@ XvQueryAdaptors(
pf = pfs;
for (jj = 0; jj < pa->num_formats; jj++) {
+ if (u.buffer + sz_xvFormat > end) {
+ Xfree(pfs);
+ status = XvBadReply;
+ goto out;
+ }
pf->depth = u.pf->depth;
pf->visual_id = u.pf->visual;
pf++;
@@ -327,6 +336,7 @@ XvQueryEncodings(
size_t size;
unsigned int jj;
char *name;
+ char *end;
XvEncodingInfo *pes = NULL, *pe;
char *buffer = NULL;
union {
@@ -364,17 +374,13 @@ XvQueryEncodings(
/* GET ENCODINGS */
if (rep.num_encodings == 0) {
- /* If there's no encodings, there's nothing more to do. */
+ /* If there are no encodings, there's nothing more to do. */
status = Success;
goto out;
}
- if (size < (rep.num_encodings * sz_xvEncodingInfo)) {
- /* If there's not enough data for the number of adaptors,
- then we have a problem. */
- status = XvBadReply;
- goto out;
- }
+ u.buffer = buffer;
+ end = buffer + size;
size = rep.num_encodings * sizeof(XvEncodingInfo);
if ((pes = Xmalloc(size)) == NULL) {
@@ -391,10 +397,12 @@ XvQueryEncodings(
pe++;
}
- u.buffer = buffer;
-
pe = pes;
for (jj = 0; jj < rep.num_encodings; jj++) {
+ if (u.buffer + sz_xvEncodingInfo > end) {
+ status = XvBadReply;
+ goto out;
+ }
pe->encoding_id = u.pe->encoding;
pe->width = u.pe->width;
pe->height = u.pe->height;
@@ -405,6 +413,10 @@ XvQueryEncodings(
size = u.pe->name_size;
u.buffer += pad_to_int32(sz_xvEncodingInfo);
+ if (u.buffer + size > end) {
+ status = XvBadReply;
+ goto out;
+ }
if ((name = Xmalloc(size + 1)) == NULL) {
status = XvBadAlloc;
goto out;
|
CWE-125
| null | null |
8,270
|
account_type_from_pwent (struct passwd *pwent)
{
struct group *grp;
gid_t wheel;
gid_t *groups;
gint ngroups;
gint i;
if (pwent->pw_uid == 0) {
g_debug ("user is root so account type is administrator");
return ACCOUNT_TYPE_ADMINISTRATOR;
}
grp = getgrnam ("wheel");
if (grp == NULL) {
g_debug ("wheel group not found");
return ACCOUNT_TYPE_STANDARD;
}
wheel = grp->gr_gid;
ngroups = get_user_groups (pwent->pw_name, pwent->pw_gid, &groups);
for (i = 0; i < ngroups; i++) {
if (groups[i] == wheel) {
g_free (groups);
return ACCOUNT_TYPE_ADMINISTRATOR;
}
}
g_free (groups);
return ACCOUNT_TYPE_STANDARD;
}
| null | 0
|
account_type_from_pwent (struct passwd *pwent)
{
struct group *grp;
gid_t wheel;
gid_t *groups;
gint ngroups;
gint i;
if (pwent->pw_uid == 0) {
g_debug ("user is root so account type is administrator");
return ACCOUNT_TYPE_ADMINISTRATOR;
}
grp = getgrnam ("wheel");
if (grp == NULL) {
g_debug ("wheel group not found");
return ACCOUNT_TYPE_STANDARD;
}
wheel = grp->gr_gid;
ngroups = get_user_groups (pwent->pw_name, pwent->pw_gid, &groups);
for (i = 0; i < ngroups; i++) {
if (groups[i] == wheel) {
g_free (groups);
return ACCOUNT_TYPE_ADMINISTRATOR;
}
}
g_free (groups);
return ACCOUNT_TYPE_STANDARD;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,271
|
compute_object_path (User *user)
{
gchar *object_path;
object_path = g_strdup_printf ("/org/freedesktop/Accounts/User%ld",
(long) user->uid);
return object_path;
}
| null | 0
|
compute_object_path (User *user)
{
gchar *object_path;
object_path = g_strdup_printf ("/org/freedesktop/Accounts/User%ld",
(long) user->uid);
return object_path;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,272
|
move_extra_data (const gchar *old_name,
const gchar *new_name)
{
gchar *old_filename;
gchar *new_filename;
old_filename = g_build_filename ("/var/lib/AccountsService/users",
old_name, NULL);
new_filename = g_build_filename ("/var/lib/AccountsService/users",
new_name, NULL);
g_rename (old_filename, new_filename);
g_free (old_filename);
g_free (new_filename);
}
| null | 0
|
move_extra_data (const gchar *old_name,
const gchar *new_name)
{
gchar *old_filename;
gchar *new_filename;
old_filename = g_build_filename ("/var/lib/AccountsService/users",
old_name, NULL);
new_filename = g_build_filename ("/var/lib/AccountsService/users",
new_name, NULL);
g_rename (old_filename, new_filename);
g_free (old_filename);
g_free (new_filename);
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,273
|
save_extra_data (User *user)
{
gchar *filename;
GKeyFile *keyfile;
gchar *data;
GError *error;
keyfile = g_key_file_new ();
user_local_save_to_keyfile (user, keyfile);
error = NULL;
data = g_key_file_to_data (keyfile, NULL, &error);
if (error == NULL) {
filename = g_build_filename ("/var/lib/AccountsService/users",
user->user_name,
NULL);
g_file_set_contents (filename, data, -1, &error);
g_free (filename);
}
if (error) {
g_warning ("Saving data for user %s failed: %s",
user->user_name, error->message);
g_error_free (error);
}
g_key_file_free (keyfile);
}
| null | 0
|
save_extra_data (User *user)
{
gchar *filename;
GKeyFile *keyfile;
gchar *data;
GError *error;
keyfile = g_key_file_new ();
user_local_save_to_keyfile (user, keyfile);
error = NULL;
data = g_key_file_to_data (keyfile, NULL, &error);
if (error == NULL) {
filename = g_build_filename ("/var/lib/AccountsService/users",
user->user_name,
NULL);
g_file_set_contents (filename, data, -1, &error);
g_free (filename);
}
if (error) {
g_warning ("Saving data for user %s failed: %s",
user->user_name, error->message);
g_error_free (error);
}
g_key_file_free (keyfile);
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,274
|
throw_error (GDBusMethodInvocation *context,
gint error_code,
const gchar *format,
...)
{
va_list args;
gchar *message;
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
g_dbus_method_invocation_return_error (context, ERROR, error_code, "%s", message);
g_free (message);
}
| null | 0
|
throw_error (GDBusMethodInvocation *context,
gint error_code,
const gchar *format,
...)
{
va_list args;
gchar *message;
va_start (args, format);
message = g_strdup_vprintf (format, args);
va_end (args);
g_dbus_method_invocation_return_error (context, ERROR, error_code, "%s", message);
g_free (message);
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,275
|
user_change_real_name_authorized_cb (Daemon *daemon,
User *user,
GDBusMethodInvocation *context,
gpointer data)
{
gchar *name = data;
GError *error;
const gchar *argv[6];
if (g_strcmp0 (user->real_name, name) != 0) {
sys_log (context,
"change real name of user '%s' (%d) to '%s'",
user->user_name, user->uid, name);
argv[0] = "/usr/sbin/usermod";
argv[1] = "-c";
argv[2] = name;
argv[3] = "--";
argv[4] = user->user_name;
argv[5] = NULL;
error = NULL;
if (!spawn_with_login_uid (context, argv, &error)) {
throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
g_error_free (error);
return;
}
g_free (user->real_name);
user->real_name = g_strdup (name);
accounts_user_emit_changed (ACCOUNTS_USER (user));
g_object_notify (G_OBJECT (user), "real-name");
}
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
| null | 0
|
user_change_real_name_authorized_cb (Daemon *daemon,
User *user,
GDBusMethodInvocation *context,
gpointer data)
{
gchar *name = data;
GError *error;
const gchar *argv[6];
if (g_strcmp0 (user->real_name, name) != 0) {
sys_log (context,
"change real name of user '%s' (%d) to '%s'",
user->user_name, user->uid, name);
argv[0] = "/usr/sbin/usermod";
argv[1] = "-c";
argv[2] = name;
argv[3] = "--";
argv[4] = user->user_name;
argv[5] = NULL;
error = NULL;
if (!spawn_with_login_uid (context, argv, &error)) {
throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
g_error_free (error);
return;
}
g_free (user->real_name);
user->real_name = g_strdup (name);
accounts_user_emit_changed (ACCOUNTS_USER (user));
g_object_notify (G_OBJECT (user), "real-name");
}
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,276
|
user_local_get_object_path (User *user)
{
return user->object_path;
}
| null | 0
|
user_local_get_object_path (User *user)
{
return user->object_path;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,277
|
user_local_get_shell(User *user)
{
return user->shell;
}
| null | 0
|
user_local_get_shell(User *user)
{
return user->shell;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,278
|
user_local_get_system_account (User *user)
{
return user->system_account;
}
| null | 0
|
user_local_get_system_account (User *user)
{
return user->system_account;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,279
|
user_local_get_uid (User *user)
{
return user->uid;
}
| null | 0
|
user_local_get_uid (User *user)
{
return user->uid;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,280
|
user_local_get_user_name (User *user)
{
return user->user_name;
}
| null | 0
|
user_local_get_user_name (User *user)
{
return user->user_name;
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,281
|
user_local_register (User *user)
{
GError *error = NULL;
user->system_bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (user->system_bus_connection == NULL) {
if (error != NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
}
return;
}
user->object_path = compute_object_path (user);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (user),
user->system_bus_connection,
user->object_path,
&error)) {
if (error != NULL) {
g_critical ("error exporting user object: %s", error->message);
g_error_free (error);
}
return;
}
}
| null | 0
|
user_local_register (User *user)
{
GError *error = NULL;
user->system_bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (user->system_bus_connection == NULL) {
if (error != NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
}
return;
}
user->object_path = compute_object_path (user);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (user),
user->system_bus_connection,
user->object_path,
&error)) {
if (error != NULL) {
g_critical ("error exporting user object: %s", error->message);
g_error_free (error);
}
return;
}
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,282
|
user_local_save_to_keyfile (User *user,
GKeyFile *keyfile)
{
if (user->email)
g_key_file_set_string (keyfile, "User", "Email", user->email);
if (user->language)
g_key_file_set_string (keyfile, "User", "Language", user->language);
if (user->x_session)
g_key_file_set_string (keyfile, "User", "XSession", user->x_session);
if (user->location)
g_key_file_set_string (keyfile, "User", "Location", user->location);
if (user->password_hint)
g_key_file_set_string (keyfile, "User", "PasswordHint", user->password_hint);
if (user->icon_file)
g_key_file_set_string (keyfile, "User", "Icon", user->icon_file);
}
| null | 0
|
user_local_save_to_keyfile (User *user,
GKeyFile *keyfile)
{
if (user->email)
g_key_file_set_string (keyfile, "User", "Email", user->email);
if (user->language)
g_key_file_set_string (keyfile, "User", "Language", user->language);
if (user->x_session)
g_key_file_set_string (keyfile, "User", "XSession", user->x_session);
if (user->location)
g_key_file_set_string (keyfile, "User", "Location", user->location);
if (user->password_hint)
g_key_file_set_string (keyfile, "User", "PasswordHint", user->password_hint);
if (user->icon_file)
g_key_file_set_string (keyfile, "User", "Icon", user->icon_file);
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,283
|
user_local_unregister (User *user)
{
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (user));
}
| null | 0
|
user_local_unregister (User *user)
{
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (user));
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,284
|
user_local_update_from_keyfile (User *user,
GKeyFile *keyfile)
{
gchar *s;
g_object_freeze_notify (G_OBJECT (user));
s = g_key_file_get_string (keyfile, "User", "Language", NULL);
if (s != NULL) {
/* TODO: validate / normalize */
g_free (user->language);
user->language = s;
}
s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
if (s != NULL) {
g_free (user->x_session);
user->x_session = s;
}
s = g_key_file_get_string (keyfile, "User", "Email", NULL);
if (s != NULL) {
g_free (user->email);
user->email = s;
}
s = g_key_file_get_string (keyfile, "User", "Location", NULL);
if (s != NULL) {
g_free (user->location);
user->location = s;
}
s = g_key_file_get_string (keyfile, "User", "PasswordHint", NULL);
if (s != NULL) {
g_free (user->password_hint);
user->password_hint = s;
}
s = g_key_file_get_string (keyfile, "User", "Icon", NULL);
if (s != NULL) {
g_free (user->icon_file);
user->icon_file = s;
}
g_object_thaw_notify (G_OBJECT (user));
}
| null | 0
|
user_local_update_from_keyfile (User *user,
GKeyFile *keyfile)
{
gchar *s;
g_object_freeze_notify (G_OBJECT (user));
s = g_key_file_get_string (keyfile, "User", "Language", NULL);
if (s != NULL) {
/* TODO: validate / normalize */
g_free (user->language);
user->language = s;
}
s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
if (s != NULL) {
g_free (user->x_session);
user->x_session = s;
}
s = g_key_file_get_string (keyfile, "User", "Email", NULL);
if (s != NULL) {
g_free (user->email);
user->email = s;
}
s = g_key_file_get_string (keyfile, "User", "Location", NULL);
if (s != NULL) {
g_free (user->location);
user->location = s;
}
s = g_key_file_get_string (keyfile, "User", "PasswordHint", NULL);
if (s != NULL) {
g_free (user->password_hint);
user->password_hint = s;
}
s = g_key_file_get_string (keyfile, "User", "Icon", NULL);
if (s != NULL) {
g_free (user->icon_file);
user->icon_file = s;
}
g_object_thaw_notify (G_OBJECT (user));
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,285
|
user_local_update_from_pwent (User *user,
struct passwd *pwent)
{
#ifdef HAVE_SHADOW_H
struct spwd *spent;
#endif
gchar *real_name;
gboolean changed;
const gchar *passwd;
gboolean locked;
PasswordMode mode;
g_object_freeze_notify (G_OBJECT (user));
changed = FALSE;
if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') {
gchar *first_comma = NULL;
gchar *valid_utf8_name = NULL;
if (g_utf8_validate (pwent->pw_gecos, -1, NULL)) {
valid_utf8_name = pwent->pw_gecos;
first_comma = g_utf8_strchr (valid_utf8_name, -1, ',');
}
else {
g_warning ("User %s has invalid UTF-8 in GECOS field. "
"It would be a good thing to check /etc/passwd.",
pwent->pw_name ? pwent->pw_name : "");
}
if (first_comma) {
real_name = g_strndup (valid_utf8_name,
(first_comma - valid_utf8_name));
}
else if (valid_utf8_name) {
real_name = g_strdup (valid_utf8_name);
}
else {
real_name = NULL;
}
if (real_name && real_name[0] == '\0') {
g_free (real_name);
real_name = NULL;
}
}
else {
real_name = NULL;
}
if (g_strcmp0 (real_name, user->real_name) != 0) {
g_free (user->real_name);
user->real_name = real_name;
changed = TRUE;
g_object_notify (G_OBJECT (user), "real-name");
}
else {
g_free (real_name);
}
/* UID */
if (pwent->pw_uid != user->uid) {
user->uid = pwent->pw_uid;
changed = TRUE;
g_object_notify (G_OBJECT (user), "uid");
}
/* GID */
user->gid = pwent->pw_gid;
user->account_type = account_type_from_pwent (pwent);
/* Username */
if (g_strcmp0 (user->user_name, pwent->pw_name) != 0) {
g_free (user->user_name);
user->user_name = g_strdup (pwent->pw_name);
changed = TRUE;
g_object_notify (G_OBJECT (user), "user-name");
}
/* Home Directory */
if (g_strcmp0 (user->home_dir, pwent->pw_dir) != 0) {
g_free (user->home_dir);
user->home_dir = g_strdup (pwent->pw_dir);
g_free (user->default_icon_file);
user->default_icon_file = g_build_filename (user->home_dir, ".face", NULL);
changed = TRUE;
g_object_notify (G_OBJECT (user), "home-directory");
}
/* Shell */
if (g_strcmp0 (user->shell, pwent->pw_shell) != 0) {
g_free (user->shell);
user->shell = g_strdup (pwent->pw_shell);
changed = TRUE;
g_object_notify (G_OBJECT (user), "shell");
}
passwd = pwent->pw_passwd;
#ifdef HAVE_SHADOW_H
spent = getspnam (pwent->pw_name);
if (spent)
passwd = spent->sp_pwdp;
#endif
if (passwd && passwd[0] == '!') {
locked = TRUE;
}
else {
locked = FALSE;
}
if (user->locked != locked) {
user->locked = locked;
changed = TRUE;
g_object_notify (G_OBJECT (user), "locked");
}
if (passwd && passwd[0] != 0) {
mode = PASSWORD_MODE_REGULAR;
}
else {
mode = PASSWORD_MODE_NONE;
}
#ifdef HAVE_SHADOW_H
if (spent) {
if (spent->sp_lstchg == 0) {
mode = PASSWORD_MODE_SET_AT_LOGIN;
}
}
#endif
if (user->password_mode != mode) {
user->password_mode = mode;
changed = TRUE;
g_object_notify (G_OBJECT (user), "password-mode");
}
user->system_account = daemon_local_user_is_excluded (user->daemon,
user->user_name,
pwent->pw_shell);
g_object_thaw_notify (G_OBJECT (user));
if (changed)
accounts_user_emit_changed (ACCOUNTS_USER (user));
}
| null | 0
|
user_local_update_from_pwent (User *user,
struct passwd *pwent)
{
#ifdef HAVE_SHADOW_H
struct spwd *spent;
#endif
gchar *real_name;
gboolean changed;
const gchar *passwd;
gboolean locked;
PasswordMode mode;
g_object_freeze_notify (G_OBJECT (user));
changed = FALSE;
if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') {
gchar *first_comma = NULL;
gchar *valid_utf8_name = NULL;
if (g_utf8_validate (pwent->pw_gecos, -1, NULL)) {
valid_utf8_name = pwent->pw_gecos;
first_comma = g_utf8_strchr (valid_utf8_name, -1, ',');
}
else {
g_warning ("User %s has invalid UTF-8 in GECOS field. "
"It would be a good thing to check /etc/passwd.",
pwent->pw_name ? pwent->pw_name : "");
}
if (first_comma) {
real_name = g_strndup (valid_utf8_name,
(first_comma - valid_utf8_name));
}
else if (valid_utf8_name) {
real_name = g_strdup (valid_utf8_name);
}
else {
real_name = NULL;
}
if (real_name && real_name[0] == '\0') {
g_free (real_name);
real_name = NULL;
}
}
else {
real_name = NULL;
}
if (g_strcmp0 (real_name, user->real_name) != 0) {
g_free (user->real_name);
user->real_name = real_name;
changed = TRUE;
g_object_notify (G_OBJECT (user), "real-name");
}
else {
g_free (real_name);
}
/* UID */
if (pwent->pw_uid != user->uid) {
user->uid = pwent->pw_uid;
changed = TRUE;
g_object_notify (G_OBJECT (user), "uid");
}
/* GID */
user->gid = pwent->pw_gid;
user->account_type = account_type_from_pwent (pwent);
/* Username */
if (g_strcmp0 (user->user_name, pwent->pw_name) != 0) {
g_free (user->user_name);
user->user_name = g_strdup (pwent->pw_name);
changed = TRUE;
g_object_notify (G_OBJECT (user), "user-name");
}
/* Home Directory */
if (g_strcmp0 (user->home_dir, pwent->pw_dir) != 0) {
g_free (user->home_dir);
user->home_dir = g_strdup (pwent->pw_dir);
g_free (user->default_icon_file);
user->default_icon_file = g_build_filename (user->home_dir, ".face", NULL);
changed = TRUE;
g_object_notify (G_OBJECT (user), "home-directory");
}
/* Shell */
if (g_strcmp0 (user->shell, pwent->pw_shell) != 0) {
g_free (user->shell);
user->shell = g_strdup (pwent->pw_shell);
changed = TRUE;
g_object_notify (G_OBJECT (user), "shell");
}
passwd = pwent->pw_passwd;
#ifdef HAVE_SHADOW_H
spent = getspnam (pwent->pw_name);
if (spent)
passwd = spent->sp_pwdp;
#endif
if (passwd && passwd[0] == '!') {
locked = TRUE;
}
else {
locked = FALSE;
}
if (user->locked != locked) {
user->locked = locked;
changed = TRUE;
g_object_notify (G_OBJECT (user), "locked");
}
if (passwd && passwd[0] != 0) {
mode = PASSWORD_MODE_REGULAR;
}
else {
mode = PASSWORD_MODE_NONE;
}
#ifdef HAVE_SHADOW_H
if (spent) {
if (spent->sp_lstchg == 0) {
mode = PASSWORD_MODE_SET_AT_LOGIN;
}
}
#endif
if (user->password_mode != mode) {
user->password_mode = mode;
changed = TRUE;
g_object_notify (G_OBJECT (user), "password-mode");
}
user->system_account = daemon_local_user_is_excluded (user->daemon,
user->user_name,
pwent->pw_shell);
g_object_thaw_notify (G_OBJECT (user));
if (changed)
accounts_user_emit_changed (ACCOUNTS_USER (user));
}
|
@@ -552,35 +552,21 @@ user_change_real_name_authorized_cb (Daemon *daemon,
accounts_user_complete_set_real_name (ACCOUNTS_USER (user), context);
}
-static uid_t
-method_invocation_get_uid (GDBusMethodInvocation *context)
-{
- const gchar *sender;
- PolkitSubject *busname;
- PolkitSubject *process;
- uid_t uid;
-
- sender = g_dbus_method_invocation_get_sender (context);
- busname = polkit_system_bus_name_new (sender);
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (busname), NULL, NULL);
- uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
- g_object_unref (busname);
- g_object_unref (process);
-
- return uid;
-}
-
static gboolean
user_set_real_name (AccountsUser *auser,
GDBusMethodInvocation *context,
const gchar *real_name)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -692,11 +678,15 @@ user_set_email (AccountsUser *auser,
const gchar *email)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -744,11 +734,15 @@ user_set_language (AccountsUser *auser,
const gchar *language)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -794,11 +788,15 @@ user_set_x_session (AccountsUser *auser,
const gchar *x_session)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -844,11 +842,15 @@ user_set_location (AccountsUser *auser,
const gchar *location)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
@@ -1163,11 +1165,15 @@ user_set_icon_file (AccountsUser *auser,
const gchar *filename)
{
User *user = (User*)auser;
- uid_t uid;
+ int uid;
const gchar *action_id;
- uid = method_invocation_get_uid (context);
- if (user->uid == uid)
+ if (!get_caller_uid (context, &uid)) {
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
+ return FALSE;
+ }
+
+ if (user->uid == (uid_t) uid)
action_id = "org.freedesktop.accounts.change-own-user-data";
else
action_id = "org.freedesktop.accounts.user-administration";
|
CWE-362
| null | null |
8,286
|
get_caller_loginuid (GDBusMethodInvocation *context, gchar *loginuid, gint size)
{
PolkitSubject *subject;
gchar *cmdline;
gint pid;
gint uid;
gchar *path;
gchar *buf;
subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
cmdline = _polkit_subject_get_cmdline (subject, &pid, &uid);
g_free (cmdline);
g_object_unref (subject);
path = g_strdup_printf ("/proc/%d/loginuid", pid);
if (g_file_get_contents (path, &buf, NULL, NULL)) {
strncpy (loginuid, buf, size);
g_free (buf);
}
else {
g_snprintf (loginuid, size, "%d", uid);
}
g_free (path);
}
| null | 0
|
get_caller_loginuid (GDBusMethodInvocation *context, gchar *loginuid, gint size)
{
PolkitSubject *subject;
gchar *cmdline;
gint pid;
gint uid;
gchar *path;
gchar *buf;
subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
cmdline = _polkit_subject_get_cmdline (subject, &pid, &uid);
g_free (cmdline);
g_object_unref (subject);
path = g_strdup_printf ("/proc/%d/loginuid", pid);
if (g_file_get_contents (path, &buf, NULL, NULL)) {
strncpy (loginuid, buf, size);
g_free (buf);
}
else {
g_snprintf (loginuid, size, "%d", uid);
}
g_free (path);
}
|
@@ -251,22 +251,37 @@ get_user_groups (const gchar *user,
gboolean
-get_caller_uid (GDBusMethodInvocation *context, gint *uid)
+get_caller_uid (GDBusMethodInvocation *context,
+ gint *uid)
{
- PolkitSubject *subject;
- PolkitSubject *process;
+ GVariant *reply;
+ GError *error;
+
+ error = NULL;
+ reply = g_dbus_connection_call_sync (g_dbus_method_invocation_get_connection (context),
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixUser",
+ g_variant_new ("(s)",
+ g_dbus_method_invocation_get_sender (context)),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (reply == NULL) {
+ g_warning ("Could not talk to message bus to find uid of sender %s: %s",
+ g_dbus_method_invocation_get_sender (context),
+ error->message);
+ g_error_free (error);
- subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);
- if (!process) {
- g_object_unref (subject);
return FALSE;
}
- *uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
-
- g_object_unref (subject);
- g_object_unref (process);
+ g_variant_get (reply, "(u)", uid);
+ g_variant_unref (reply);
return TRUE;
}
|
CWE-362
| null | null |
8,287
|
get_user_groups (const gchar *user,
gid_t group,
gid_t **groups)
{
gint res;
gint ngroups;
ngroups = 0;
res = getgrouplist (user, group, NULL, &ngroups);
g_debug ("user %s has %d groups\n", user, ngroups);
*groups = g_new (gid_t, ngroups);
res = getgrouplist (user, group, *groups, &ngroups);
return res;
}
| null | 0
|
get_user_groups (const gchar *user,
gid_t group,
gid_t **groups)
{
gint res;
gint ngroups;
ngroups = 0;
res = getgrouplist (user, group, NULL, &ngroups);
g_debug ("user %s has %d groups\n", user, ngroups);
*groups = g_new (gid_t, ngroups);
res = getgrouplist (user, group, *groups, &ngroups);
return res;
}
|
@@ -251,22 +251,37 @@ get_user_groups (const gchar *user,
gboolean
-get_caller_uid (GDBusMethodInvocation *context, gint *uid)
+get_caller_uid (GDBusMethodInvocation *context,
+ gint *uid)
{
- PolkitSubject *subject;
- PolkitSubject *process;
+ GVariant *reply;
+ GError *error;
+
+ error = NULL;
+ reply = g_dbus_connection_call_sync (g_dbus_method_invocation_get_connection (context),
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixUser",
+ g_variant_new ("(s)",
+ g_dbus_method_invocation_get_sender (context)),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (reply == NULL) {
+ g_warning ("Could not talk to message bus to find uid of sender %s: %s",
+ g_dbus_method_invocation_get_sender (context),
+ error->message);
+ g_error_free (error);
- subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);
- if (!process) {
- g_object_unref (subject);
return FALSE;
}
- *uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
-
- g_object_unref (subject);
- g_object_unref (process);
+ g_variant_get (reply, "(u)", uid);
+ g_variant_unref (reply);
return TRUE;
}
|
CWE-362
| null | null |
8,288
|
setup_loginuid (gpointer data)
{
const char *id = data;
int fd;
fd = open ("/proc/self/loginuid", O_WRONLY);
write (fd, id, strlen (id));
close (fd);
}
| null | 0
|
setup_loginuid (gpointer data)
{
const char *id = data;
int fd;
fd = open ("/proc/self/loginuid", O_WRONLY);
write (fd, id, strlen (id));
close (fd);
}
|
@@ -251,22 +251,37 @@ get_user_groups (const gchar *user,
gboolean
-get_caller_uid (GDBusMethodInvocation *context, gint *uid)
+get_caller_uid (GDBusMethodInvocation *context,
+ gint *uid)
{
- PolkitSubject *subject;
- PolkitSubject *process;
+ GVariant *reply;
+ GError *error;
+
+ error = NULL;
+ reply = g_dbus_connection_call_sync (g_dbus_method_invocation_get_connection (context),
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixUser",
+ g_variant_new ("(s)",
+ g_dbus_method_invocation_get_sender (context)),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (reply == NULL) {
+ g_warning ("Could not talk to message bus to find uid of sender %s: %s",
+ g_dbus_method_invocation_get_sender (context),
+ error->message);
+ g_error_free (error);
- subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);
- if (!process) {
- g_object_unref (subject);
return FALSE;
}
- *uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
-
- g_object_unref (subject);
- g_object_unref (process);
+ g_variant_get (reply, "(u)", uid);
+ g_variant_unref (reply);
return TRUE;
}
|
CWE-362
| null | null |
8,289
|
sys_log (GDBusMethodInvocation *context,
const gchar *format,
...)
{
va_list args;
gchar *msg;
va_start (args, format);
msg = g_strdup_vprintf (format, args);
va_end (args);
if (context) {
PolkitSubject *subject;
gchar *cmdline;
gchar *id;
gint pid = 0;
gint uid = 0;
gchar *tmp;
subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
id = polkit_subject_to_string (subject);
cmdline = _polkit_subject_get_cmdline (subject, &pid, &uid);
if (cmdline == NULL) {
tmp = g_strdup_printf ("request by %s: %s", id, msg);
}
else {
tmp = g_strdup_printf ("request by %s [%s pid:%d uid:%d]: %s", id, cmdline, pid, uid, msg);
}
g_free (msg);
msg = tmp;
g_free (id);
g_free (cmdline);
g_object_unref (subject);
}
syslog (LOG_NOTICE, "%s", msg);
g_free (msg);
}
| null | 0
|
sys_log (GDBusMethodInvocation *context,
const gchar *format,
...)
{
va_list args;
gchar *msg;
va_start (args, format);
msg = g_strdup_vprintf (format, args);
va_end (args);
if (context) {
PolkitSubject *subject;
gchar *cmdline;
gchar *id;
gint pid = 0;
gint uid = 0;
gchar *tmp;
subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
id = polkit_subject_to_string (subject);
cmdline = _polkit_subject_get_cmdline (subject, &pid, &uid);
if (cmdline == NULL) {
tmp = g_strdup_printf ("request by %s: %s", id, msg);
}
else {
tmp = g_strdup_printf ("request by %s [%s pid:%d uid:%d]: %s", id, cmdline, pid, uid, msg);
}
g_free (msg);
msg = tmp;
g_free (id);
g_free (cmdline);
g_object_unref (subject);
}
syslog (LOG_NOTICE, "%s", msg);
g_free (msg);
}
|
@@ -251,22 +251,37 @@ get_user_groups (const gchar *user,
gboolean
-get_caller_uid (GDBusMethodInvocation *context, gint *uid)
+get_caller_uid (GDBusMethodInvocation *context,
+ gint *uid)
{
- PolkitSubject *subject;
- PolkitSubject *process;
+ GVariant *reply;
+ GError *error;
+
+ error = NULL;
+ reply = g_dbus_connection_call_sync (g_dbus_method_invocation_get_connection (context),
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixUser",
+ g_variant_new ("(s)",
+ g_dbus_method_invocation_get_sender (context)),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (reply == NULL) {
+ g_warning ("Could not talk to message bus to find uid of sender %s: %s",
+ g_dbus_method_invocation_get_sender (context),
+ error->message);
+ g_error_free (error);
- subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
- process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);
- if (!process) {
- g_object_unref (subject);
return FALSE;
}
- *uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (process));
-
- g_object_unref (subject);
- g_object_unref (process);
+ g_variant_get (reply, "(u)", uid);
+ g_variant_unref (reply);
return TRUE;
}
|
CWE-362
| null | null |
8,290
|
FcCacheFindByAddr (void *object)
{
FcCacheSkip *ret;
lock_cache ();
ret = FcCacheFindByAddrUnlocked (object);
unlock_cache ();
return ret;
}
|
Exec Code
| 0
|
FcCacheFindByAddr (void *object)
{
FcCacheSkip *ret;
lock_cache ();
ret = FcCacheFindByAddrUnlocked (object);
unlock_cache ();
return ret;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,291
|
FcCacheFindByAddrUnlocked (void *object)
{
int i;
FcCacheSkip **next = fcCacheChains;
FcCacheSkip *s;
if (!object)
return NULL;
/*
* Walk chain pointers one level at a time
*/
for (i = fcCacheMaxLevel; --i >= 0;)
while (next[i] && (char *) object >= ((char *) next[i]->cache + next[i]->size))
next = next[i]->next;
/*
* Here we are
*/
s = next[0];
if (s && (char *) object < ((char *) s->cache + s->size))
return s;
return NULL;
}
|
Exec Code
| 0
|
FcCacheFindByAddrUnlocked (void *object)
{
int i;
FcCacheSkip **next = fcCacheChains;
FcCacheSkip *s;
if (!object)
return NULL;
/*
* Walk chain pointers one level at a time
*/
for (i = fcCacheMaxLevel; --i >= 0;)
while (next[i] && (char *) object >= ((char *) next[i]->cache + next[i]->size))
next = next[i]->next;
/*
* Here we are
*/
s = next[0];
if (s && (char *) object < ((char *) s->cache + s->size))
return s;
return NULL;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,292
|
FcCacheFindByStat (struct stat *cache_stat)
{
FcCacheSkip *s;
lock_cache ();
for (s = fcCacheChains[0]; s; s = s->next[0])
if (s->cache_dev == cache_stat->st_dev &&
s->cache_ino == cache_stat->st_ino &&
s->cache_mtime == cache_stat->st_mtime)
{
#ifdef HAVE_STRUCT_STAT_ST_MTIM
if (s->cache_mtime != cache_stat->st_mtim.tv_nsec)
continue;
#endif
FcRefInc (&s->ref);
unlock_cache ();
return s->cache;
}
unlock_cache ();
return NULL;
}
|
Exec Code
| 0
|
FcCacheFindByStat (struct stat *cache_stat)
{
FcCacheSkip *s;
lock_cache ();
for (s = fcCacheChains[0]; s; s = s->next[0])
if (s->cache_dev == cache_stat->st_dev &&
s->cache_ino == cache_stat->st_ino &&
s->cache_mtime == cache_stat->st_mtime)
{
#ifdef HAVE_STRUCT_STAT_ST_MTIM
if (s->cache_mtime != cache_stat->st_mtim.tv_nsec)
continue;
#endif
FcRefInc (&s->ref);
unlock_cache ();
return s->cache;
}
unlock_cache ();
return NULL;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,293
|
FcCacheFini (void)
{
int i;
for (i = 0; i < FC_CACHE_MAX_LEVEL; i++)
assert (fcCacheChains[i] == NULL);
assert (fcCacheMaxLevel == 0);
free_lock ();
}
|
Exec Code
| 0
|
FcCacheFini (void)
{
int i;
for (i = 0; i < FC_CACHE_MAX_LEVEL; i++)
assert (fcCacheChains[i] == NULL);
assert (fcCacheMaxLevel == 0);
free_lock ();
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,294
|
FcCacheInsert (FcCache *cache, struct stat *cache_stat)
{
FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
FcCacheSkip *s, **next;
int i, level;
lock_cache ();
/*
* Find links along each chain
*/
next = fcCacheChains;
for (i = fcCacheMaxLevel; --i >= 0; )
{
for (; (s = next[i]); next = s->next)
if (s->cache > cache)
break;
update[i] = &next[i];
}
/*
* Create new list element
*/
level = random_level ();
if (level > fcCacheMaxLevel)
{
level = fcCacheMaxLevel + 1;
update[fcCacheMaxLevel] = &fcCacheChains[fcCacheMaxLevel];
fcCacheMaxLevel = level;
}
s = malloc (sizeof (FcCacheSkip) + (level - 1) * sizeof (FcCacheSkip *));
if (!s)
return FcFalse;
s->cache = cache;
s->size = cache->size;
FcRefInit (&s->ref, 1);
if (cache_stat)
{
s->cache_dev = cache_stat->st_dev;
s->cache_ino = cache_stat->st_ino;
s->cache_mtime = cache_stat->st_mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
s->cache_mtime_nano = cache_stat->st_mtim.tv_nsec;
#else
s->cache_mtime_nano = 0;
#endif
}
else
{
s->cache_dev = 0;
s->cache_ino = 0;
s->cache_mtime = 0;
s->cache_mtime_nano = 0;
}
/*
* Insert into all fcCacheChains
*/
for (i = 0; i < level; i++)
{
s->next[i] = *update[i];
*update[i] = s;
}
unlock_cache ();
return FcTrue;
}
|
Exec Code
| 0
|
FcCacheInsert (FcCache *cache, struct stat *cache_stat)
{
FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
FcCacheSkip *s, **next;
int i, level;
lock_cache ();
/*
* Find links along each chain
*/
next = fcCacheChains;
for (i = fcCacheMaxLevel; --i >= 0; )
{
for (; (s = next[i]); next = s->next)
if (s->cache > cache)
break;
update[i] = &next[i];
}
/*
* Create new list element
*/
level = random_level ();
if (level > fcCacheMaxLevel)
{
level = fcCacheMaxLevel + 1;
update[fcCacheMaxLevel] = &fcCacheChains[fcCacheMaxLevel];
fcCacheMaxLevel = level;
}
s = malloc (sizeof (FcCacheSkip) + (level - 1) * sizeof (FcCacheSkip *));
if (!s)
return FcFalse;
s->cache = cache;
s->size = cache->size;
FcRefInit (&s->ref, 1);
if (cache_stat)
{
s->cache_dev = cache_stat->st_dev;
s->cache_ino = cache_stat->st_ino;
s->cache_mtime = cache_stat->st_mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
s->cache_mtime_nano = cache_stat->st_mtim.tv_nsec;
#else
s->cache_mtime_nano = 0;
#endif
}
else
{
s->cache_dev = 0;
s->cache_ino = 0;
s->cache_mtime = 0;
s->cache_mtime_nano = 0;
}
/*
* Insert into all fcCacheChains
*/
for (i = 0; i < level; i++)
{
s->next[i] = *update[i];
*update[i] = s;
}
unlock_cache ();
return FcTrue;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,295
|
FcCacheIsMmapSafe (int fd)
{
enum {
MMAP_NOT_INITIALIZED = 0,
MMAP_USE,
MMAP_DONT_USE,
MMAP_CHECK_FS,
} status;
static void *static_status;
status = (intptr_t) fc_atomic_ptr_get (&static_status);
if (status == MMAP_NOT_INITIALIZED)
{
const char *env = getenv ("FONTCONFIG_USE_MMAP");
FcBool use;
if (env && FcNameBool ((const FcChar8 *) env, &use))
status = use ? MMAP_USE : MMAP_DONT_USE;
else
status = MMAP_CHECK_FS;
(void) fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
}
if (status == MMAP_CHECK_FS)
return FcIsFsMmapSafe (fd);
else
return status == MMAP_USE;
}
|
Exec Code
| 0
|
FcCacheIsMmapSafe (int fd)
{
enum {
MMAP_NOT_INITIALIZED = 0,
MMAP_USE,
MMAP_DONT_USE,
MMAP_CHECK_FS,
} status;
static void *static_status;
status = (intptr_t) fc_atomic_ptr_get (&static_status);
if (status == MMAP_NOT_INITIALIZED)
{
const char *env = getenv ("FONTCONFIG_USE_MMAP");
FcBool use;
if (env && FcNameBool ((const FcChar8 *) env, &use))
status = use ? MMAP_USE : MMAP_DONT_USE;
else
status = MMAP_CHECK_FS;
(void) fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
}
if (status == MMAP_CHECK_FS)
return FcIsFsMmapSafe (fd);
else
return status == MMAP_USE;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,296
|
FcCacheObjectDereference (void *object)
{
FcCacheSkip *skip;
lock_cache ();
skip = FcCacheFindByAddrUnlocked (object);
if (skip)
{
if (FcRefDec (&skip->ref) == 1)
FcDirCacheDisposeUnlocked (skip->cache);
}
unlock_cache ();
}
|
Exec Code
| 0
|
FcCacheObjectDereference (void *object)
{
FcCacheSkip *skip;
lock_cache ();
skip = FcCacheFindByAddrUnlocked (object);
if (skip)
{
if (FcRefDec (&skip->ref) == 1)
FcDirCacheDisposeUnlocked (skip->cache);
}
unlock_cache ();
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,297
|
FcCacheObjectReference (void *object)
{
FcCacheSkip *skip = FcCacheFindByAddr (object);
if (skip)
FcRefInc (&skip->ref);
}
|
Exec Code
| 0
|
FcCacheObjectReference (void *object)
{
FcCacheSkip *skip = FcCacheFindByAddr (object);
if (skip)
FcRefInc (&skip->ref);
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,298
|
FcCacheRemoveUnlocked (FcCache *cache)
{
FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
FcCacheSkip *s, **next;
int i;
/*
* Find links along each chain
*/
next = fcCacheChains;
for (i = fcCacheMaxLevel; --i >= 0; )
{
for (; (s = next[i]); next = s->next)
if (s->cache >= cache)
break;
update[i] = &next[i];
}
s = next[0];
for (i = 0; i < fcCacheMaxLevel && *update[i] == s; i++)
*update[i] = s->next[i];
while (fcCacheMaxLevel > 0 && fcCacheChains[fcCacheMaxLevel - 1] == NULL)
fcCacheMaxLevel--;
free (s);
}
|
Exec Code
| 0
|
FcCacheRemoveUnlocked (FcCache *cache)
{
FcCacheSkip **update[FC_CACHE_MAX_LEVEL];
FcCacheSkip *s, **next;
int i;
/*
* Find links along each chain
*/
next = fcCacheChains;
for (i = fcCacheMaxLevel; --i >= 0; )
{
for (; (s = next[i]); next = s->next)
if (s->cache >= cache)
break;
update[i] = &next[i];
}
s = next[0];
for (i = 0; i < fcCacheMaxLevel && *update[i] == s; i++)
*update[i] = s->next[i];
while (fcCacheMaxLevel > 0 && fcCacheChains[fcCacheMaxLevel - 1] == NULL)
fcCacheMaxLevel--;
free (s);
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
8,299
|
FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
{
struct stat dir_static;
FcBool fnano = FcTrue;
if (!dir_stat)
{
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
FcChar8 *d;
if (sysroot)
d = FcStrBuildFilename (sysroot, FcCacheDir (cache), NULL);
else
d = FcStrdup (FcCacheDir (cache));
if (FcStatChecksum (d, &dir_static) < 0)
{
FcStrFree (d);
return FcFalse;
}
FcStrFree (d);
dir_stat = &dir_static;
}
#ifdef HAVE_STRUCT_STAT_ST_MTIM
fnano = (cache->checksum_nano == dir_stat->st_mtim.tv_nsec);
if (FcDebug () & FC_DBG_CACHE)
printf ("FcCacheTimeValid dir \"%s\" cache checksum %d.%ld dir checksum %d.%ld\n",
FcCacheDir (cache), cache->checksum, (long)cache->checksum_nano, (int) dir_stat->st_mtime, dir_stat->st_mtim.tv_nsec);
#else
if (FcDebug () & FC_DBG_CACHE)
printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n",
FcCacheDir (cache), cache->checksum, (int) dir_stat->st_mtime);
#endif
return cache->checksum == (int) dir_stat->st_mtime && fnano;
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
|
Exec Code
| 0
|
FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
{
struct stat dir_static;
FcBool fnano = FcTrue;
if (!dir_stat)
{
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
FcChar8 *d;
if (sysroot)
d = FcStrBuildFilename (sysroot, FcCacheDir (cache), NULL);
else
d = FcStrdup (FcCacheDir (cache));
if (FcStatChecksum (d, &dir_static) < 0)
{
FcStrFree (d);
return FcFalse;
}
FcStrFree (d);
dir_stat = &dir_static;
}
#ifdef HAVE_STRUCT_STAT_ST_MTIM
fnano = (cache->checksum_nano == dir_stat->st_mtim.tv_nsec);
if (FcDebug () & FC_DBG_CACHE)
printf ("FcCacheTimeValid dir \"%s\" cache checksum %d.%ld dir checksum %d.%ld\n",
FcCacheDir (cache), cache->checksum, (long)cache->checksum_nano, (int) dir_stat->st_mtime, dir_stat->st_mtim.tv_nsec);
#else
if (FcDebug () & FC_DBG_CACHE)
printf ("FcCacheTimeValid dir \"%s\" cache checksum %d dir checksum %d\n",
FcCacheDir (cache), cache->checksum, (int) dir_stat->st_mtime);
#endif
return cache->checksum == (int) dir_stat->st_mtime && fnano;
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
|
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
@@ -587,6 +588,82 @@ FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
return cache->checksum == (int) dir_stat->st_mtime && fnano;
}
+static FcBool
+FcCacheOffsetsValid (FcCache *cache)
+{
+ char *base = (char *)cache;
+ char *end = base + cache->size;
+ intptr_t *dirs;
+ FcFontSet *fs;
+ int i, j;
+
+ if (cache->dir < 0 || cache->dir > cache->size - sizeof (intptr_t) ||
+ memchr (base + cache->dir, '\0', cache->size - cache->dir) == NULL)
+ return FcFalse;
+
+ if (cache->dirs < 0 || cache->dirs >= cache->size ||
+ cache->dirs_count < 0 ||
+ cache->dirs_count > (cache->size - cache->dirs) / sizeof (intptr_t))
+ return FcFalse;
+
+ dirs = FcCacheDirs (cache);
+ if (dirs)
+ {
+ for (i = 0; i < cache->dirs_count; i++)
+ {
+ FcChar8 *dir;
+
+ if (dirs[i] < 0 ||
+ dirs[i] > end - (char *) dirs - sizeof (intptr_t))
+ return FcFalse;
+
+ dir = FcOffsetToPtr (dirs, dirs[i], FcChar8);
+ if (memchr (dir, '\0', end - (char *) dir) == NULL)
+ return FcFalse;
+ }
+ }
+
+ if (cache->set < 0 || cache->set > cache->size - sizeof (FcFontSet))
+ return FcFalse;
+
+ fs = FcCacheSet (cache);
+ if (fs)
+ {
+ if (fs->nfont > (end - (char *) fs) / sizeof (FcPattern))
+ return FcFalse;
+
+ if (fs->fonts != 0 && !FcIsEncodedOffset(fs->fonts))
+ return FcFalse;
+
+ for (i = 0; i < fs->nfont; i++)
+ {
+ FcPattern *font = FcFontSetFont (fs, i);
+ FcPatternElt *e;
+ FcValueListPtr l;
+
+ if ((char *) font < base ||
+ (char *) font > end - sizeof (FcFontSet) ||
+ font->elts_offset < 0 ||
+ font->elts_offset > end - (char *) font ||
+ font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
+ return FcFalse;
+
+
+ e = FcPatternElts(font);
+ if (e->values != 0 && !FcIsEncodedOffset(e->values))
+ return FcFalse;
+
+ for (j = font->num, l = FcPatternEltValues(e); j >= 0 && l; j--, l = FcValueListNext(l))
+ if (l->next != NULL && !FcIsEncodedOffset(l->next))
+ break;
+ if (j < 0)
+ return FcFalse;
+ }
+ }
+
+ return FcTrue;
+}
+
/*
* Map a cache file into memory
*/
@@ -596,7 +673,8 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
FcCache *cache;
FcBool allocated = FcFalse;
- if (fd_stat->st_size < (int) sizeof (FcCache))
+ if (fd_stat->st_size > INTPTR_MAX ||
+ fd_stat->st_size < (int) sizeof (FcCache))
return NULL;
cache = FcCacheFindByStat (fd_stat);
if (cache)
@@ -652,6 +730,7 @@ FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *di
if (cache->magic != FC_CACHE_MAGIC_MMAP ||
cache->version < FC_CACHE_VERSION_NUMBER ||
cache->size != (intptr_t) fd_stat->st_size ||
+ !FcCacheOffsetsValid (cache) ||
!FcCacheTimeValid (config, cache, dir_stat) ||
!FcCacheInsert (cache, fd_stat))
{
|
CWE-415
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.