ref: 58b61b6e05597112f8673e5ab9bd175f59e2db5e
parent: bdb56bba866ddd3532bce008156bd3763614aa0e
author: Werner Lemberg <[email protected]>
date: Tue Oct 13 14:26:18 EDT 2015
[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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2015-10-13 Werner Lemberg <[email protected]>
+ [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 <[email protected]>
+
[ftfuzzer] Handle TTCs and MM/GX variations.
This patch also contains various other improvements.
--- a/src/pcf/pcf.h
+++ b/src/pcf/pcf.h
@@ -226,8 +226,9 @@
#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
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -271,7 +271,7 @@
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 @@
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 @@
* 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 );
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -1184,8 +1184,10 @@
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 @@
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,12 +1246,8 @@
/* 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 |