[pcf] Quickly exit if font index < 0.

Similar to other font formats, this commit makes the parser no
longer check the whole PCF file but only the header and the TOC if
we just want to get the number of available faces (and a proper
recognition of the font format).

* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
Exit quickly if face_index < 0.

* src/pcfread.c (pcf_load_font): Add `face_index' argument.
Exit quickly if face_index < 0.

* src/pcf/pcf.h: Updated.
This commit is contained in:
Werner Lemberg 2015-10-13 18:26:18 +02:00
parent bdb56bba86
commit 58b61b6e05
4 changed files with 35 additions and 10 deletions

View File

@ -1,3 +1,20 @@
2015-10-13 Werner Lemberg <wl@gnu.org>
[pcf] Quickly exit if font index < 0.
Similar to other font formats, this commit makes the parser no
longer check the whole PCF file but only the header and the TOC if
we just want to get the number of available faces (and a proper
recognition of the font format).
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
Exit quickly if face_index < 0.
* src/pcfread.c (pcf_load_font): Add `face_index' argument.
Exit quickly if face_index < 0.
* src/pcf/pcf.h: Updated.
2015-10-13 Werner Lemberg <wl@gnu.org>
[ftfuzzer] Handle TTCs and MM/GX variations.

View File

@ -226,8 +226,9 @@ FT_BEGIN_HEADER
#define GLYPHPADOPTIONS 4 /* I'm not sure about this */
FT_LOCAL( FT_Error )
pcf_load_font( FT_Stream,
PCF_Face );
pcf_load_font( FT_Stream stream,
PCF_Face face,
FT_Long face_index );
FT_END_HEADER

View File

@ -271,7 +271,7 @@ THE SOFTWARE.
FT_TRACE2(( "PCF driver\n" ));
error = pcf_load_font( stream, face );
error = pcf_load_font( stream, face, face_index );
if ( error )
{
PCF_Face_Done( pcfface );
@ -332,7 +332,7 @@ THE SOFTWARE.
stream = pcfface->stream;
error = pcf_load_font( stream, face );
error = pcf_load_font( stream, face, face_index );
if ( error )
goto Fail;
@ -351,7 +351,9 @@ THE SOFTWARE.
* an invalid argument error when the font could be
* opened by the specified driver.
*/
if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
if ( face_index < 0 )
goto Exit;
else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
{
FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
PCF_Face_Done( pcfface );

View File

@ -1184,8 +1184,10 @@ THE SOFTWARE.
FT_LOCAL_DEF( FT_Error )
pcf_load_font( FT_Stream stream,
PCF_Face face )
PCF_Face face,
FT_Long face_index )
{
FT_Face root = FT_FACE( face );
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;
@ -1195,6 +1197,13 @@ THE SOFTWARE.
if ( error )
goto Exit;
root->num_faces = 1;
root->face_index = 0;
/* If we are performing a simple font format check, exit immediately. */
if ( face_index < 0 )
return FT_Err_Ok;
error = pcf_get_properties( stream, face );
if ( error )
goto Exit;
@ -1237,13 +1246,9 @@ THE SOFTWARE.
/* now construct the face object */
{
FT_Face root = FT_FACE( face );
PCF_Property prop;
root->num_faces = 1;
root->face_index = 0;
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_FAST_GLYPHS;