[bdf, cid, pfr, winfonts] Improve rejection of other font formats.
This is mainly for better diagnostics of malformed fonts. * src/bdf/bdflib.c (_bfd_readstream): Stop font format testing if the first input line is too long or doesn't end with `\r` or `\n`. * src/cid/cidparse.c (cid_parser_new): Don't handle too short input as an error but as an unknown format. * src/pfr/pfrobjs.c (pfr_face_init): Ditto. * src/winfonts/winfnt.c (fnt_font_load, fnt_face_get_dll_font): Ditto.
This commit is contained in:
parent
38b349c41b
commit
8ef8072ba1
|
@ -581,8 +581,14 @@
|
||||||
/* or even resizing it */
|
/* or even resizing it */
|
||||||
if ( end >= avail )
|
if ( end >= avail )
|
||||||
{
|
{
|
||||||
if ( bytes == 0 ) /* last line in file doesn't end in \r or \n */
|
if ( bytes == 0 )
|
||||||
break; /* ignore it then exit */
|
{
|
||||||
|
/* last line in file doesn't end in \r or \n; */
|
||||||
|
/* ignore it then exit */
|
||||||
|
if ( lineno == 1 )
|
||||||
|
error = FT_THROW( Missing_Startfont_Field );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ( start == 0 )
|
if ( start == 0 )
|
||||||
{
|
{
|
||||||
|
@ -592,9 +598,14 @@
|
||||||
|
|
||||||
|
|
||||||
if ( buf_size >= 65536UL ) /* limit ourselves to 64KByte */
|
if ( buf_size >= 65536UL ) /* limit ourselves to 64KByte */
|
||||||
|
{
|
||||||
|
if ( lineno == 1 )
|
||||||
|
error = FT_THROW( Missing_Startfont_Field );
|
||||||
|
else
|
||||||
{
|
{
|
||||||
FT_ERROR(( "_bdf_readstream: " ERRMSG6, lineno ));
|
FT_ERROR(( "_bdf_readstream: " ERRMSG6, lineno ));
|
||||||
error = FT_THROW( Invalid_Argument );
|
error = FT_THROW( Invalid_Argument );
|
||||||
|
}
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,11 @@
|
||||||
|
|
||||||
/* first of all, check the font format in the header */
|
/* first of all, check the font format in the header */
|
||||||
if ( FT_FRAME_ENTER( 31 ) )
|
if ( FT_FRAME_ENTER( 31 ) )
|
||||||
|
{
|
||||||
|
FT_TRACE2(( " not a CID-keyed font\n" ));
|
||||||
|
error = FT_THROW( Unknown_File_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ft_strncmp( (char *)stream->cursor,
|
if ( ft_strncmp( (char *)stream->cursor,
|
||||||
"%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
|
"%!PS-Adobe-3.0 Resource-CIDFont", 31 ) )
|
||||||
|
|
|
@ -83,7 +83,11 @@
|
||||||
/* load the header and check it */
|
/* load the header and check it */
|
||||||
error = pfr_header_load( &face->header, stream );
|
error = pfr_header_load( &face->header, stream );
|
||||||
if ( error )
|
if ( error )
|
||||||
|
{
|
||||||
|
FT_TRACE2(( " not a PFR font\n" ));
|
||||||
|
error = FT_THROW( Unknown_File_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !pfr_header_check( &face->header ) )
|
if ( !pfr_header_check( &face->header ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,7 +217,11 @@
|
||||||
/* first of all, read the FNT header */
|
/* first of all, read the FNT header */
|
||||||
if ( FT_STREAM_SEEK( font->offset ) ||
|
if ( FT_STREAM_SEEK( font->offset ) ||
|
||||||
FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
|
FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
|
||||||
|
{
|
||||||
|
FT_TRACE2(( " not a Windows FNT file\n" ));
|
||||||
|
error = FT_THROW( Unknown_File_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* check header */
|
/* check header */
|
||||||
if ( header->version != 0x200 &&
|
if ( header->version != 0x200 &&
|
||||||
|
@ -284,7 +288,10 @@
|
||||||
/* does it begin with an MZ header? */
|
/* does it begin with an MZ header? */
|
||||||
if ( FT_STREAM_SEEK( 0 ) ||
|
if ( FT_STREAM_SEEK( 0 ) ||
|
||||||
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
|
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
|
||||||
|
{
|
||||||
|
error = FT_ERR( Unknown_File_Format );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
error = FT_ERR( Unknown_File_Format );
|
error = FT_ERR( Unknown_File_Format );
|
||||||
if ( mz_header.magic == WINFNT_MZ_MAGIC )
|
if ( mz_header.magic == WINFNT_MZ_MAGIC )
|
||||||
|
|
Loading…
Reference in New Issue