ref: 06c2d3324e8a8dbe153d51129adadd8d8eb4f834
parent: 983b00ec8667baf6cd6b23c420d94c681ffd2ec4
author: Werner Lemberg <[email protected]>
date: Thu Oct 8 17:31:57 EDT 2015
[type42] Protect against invalid number of glyphs (#46159). * src/type42/t42parse.c (t42_parse_charstrings): Check number of `CharStrings' dictionary entries against size of data stream.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2015-10-08 Werner Lemberg <[email protected]>
+ [type42] Protect against invalid number of glyphs (#46159).
+
+ * src/type42/t42parse.c (t42_parse_charstrings): Check number of
+ `CharStrings' dictionary entries against size of data stream.
+
+2015-10-08 Werner Lemberg <[email protected]>
+
[sfnt] Fix some signed overflows (#46149).
* src/sfnt/ttsbit.c (tt_face_load_strike_metrics)
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -795,6 +795,17 @@
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
+
+ /* we certainly need more than 4 bytes per glyph */
+ if ( loader->num_glyphs > ( limit - parser->root.cursor ) >> 2 )
+ {
+ FT_TRACE0(( "t42_parse_charstrings: adjusting number of glyphs"
+ " (from %d to %d)\n",
+ loader->num_glyphs,
+ ( limit - parser->root.cursor ) >> 2 ));
+ loader->num_glyphs = ( limit - parser->root.cursor ) >> 2;
+ }
+
}
else if ( *parser->root.cursor == '<' )
{