Commit 577414030a14219723d0536fb1a349174508062b

Werner Lemberg 2016-10-22T18:34:48

[sfnt] Improve handling of invalid post 2.5 tables [#49393]. * src/sfnt/ttpost.c (load_format_25): We need at least a single table entry.

diff --git a/ChangeLog b/ChangeLog
index 6b54ef0..3b12c20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-10-22  Werner Lemberg  <wl@gnu.org>
+
+	[sfnt] Improve handling of invalid post 2.5 tables [#49393].
+
+	* src/sfnt/ttpost.c (load_format_25): We need at least a single
+	table entry.
+
 2016-10-14  Werner Lemberg  <wl@gnu.org>
 
 	[truetype] Fix handling of `cvar' table data.
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index 3277f1e..ef81e63 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -326,7 +326,9 @@
       goto Exit;
 
     /* check the number of glyphs */
-    if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 )
+    if ( num_glyphs > face->max_profile.numGlyphs ||
+         num_glyphs > 258                         ||
+         num_glyphs < 1                           )
     {
       error = FT_THROW( Invalid_File_Format );
       goto Exit;