[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
diff --git a/ChangeLog b/ChangeLog
index b8a99e2..aa5c7b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
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.
This patch also contains various other improvements.
diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
index c0da503..253a33f 100644
--- a/src/pcf/pcf.h
+++ b/src/pcf/pcf.h
@@ -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
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 8d2ed7c..0f4c518 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -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 );
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 6a248cf..fca677f 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -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;