Commit af8346172a7b573715134f7a51e6c5c60fa7f2ab

Werner Lemberg 2014-11-22T13:29:10

[bdf] Fix Savannah bug #43660. * src/bdf/bdflib.c (_bdf_parse_glyphs) <"ENDFONT">: Check `_BDF_GLYPH_BITS'.

diff --git a/ChangeLog b/ChangeLog
index 20a79d0..aa28289 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2014-11-22  Werner Lemberg  <wl@gnu.org>
 
+	[bdf] Fix Savannah bug #43660.
+
+	* src/bdf/bdflib.c (_bdf_parse_glyphs) <"ENDFONT">: Check
+	`_BDF_GLYPH_BITS'.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
 	[type42] Allow only embedded TrueType fonts.
 
 	This is a follow-up to Savannah bug #43659.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index c128526..369c111 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1555,6 +1555,14 @@
     /* Check for the ENDFONT field. */
     if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
     {
+      if ( p->flags & _BDF_GLYPH_BITS )
+      {
+        /* Missing ENDCHAR field. */
+        FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+        error = FT_THROW( Corrupted_Font_Glyphs );
+        goto Exit;
+      }
+
       /* Sort the glyphs by encoding. */
       ft_qsort( (char *)font->glyphs,
                 font->glyphs_used,