[cff] Better check of number of blends. * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdBLEND>, src/cff/cffparse.c (cff_parse_blend): Compare number of blends with stack size.
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
diff --git a/ChangeLog b/ChangeLog
index 133ce21..627b938 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-12-28 Werner Lemberg <wl@gnu.org>
+
+ [cff] Better check of number of blends.
+
+ * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdBLEND>,
+ src/cff/cffparse.c (cff_parse_blend): Compare number of blends with
+ stack size.
+
2016-12-27 Werner Lemberg <wl@gnu.org>
Documentation updates.
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
index 078f6fe..ef52999 100644
--- a/src/cff/cf2intrp.c
+++ b/src/cff/cf2intrp.c
@@ -693,12 +693,13 @@
}
/* do the blend */
+ numBlends = (FT_UInt)cf2_stack_popInt( opStack );
+ if ( numBlends > stackSize )
{
- FT_Int temp = cf2_stack_popInt( opStack );
-
-
- numBlends = temp > 0 ? (FT_UInt)temp : 0;
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
}
+
cf2_doBlend( &font->blend, opStack, numBlends );
font->blend.usedBV = TRUE;
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index a848631..ee538c3 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -907,6 +907,12 @@
}
numBlends = (FT_UInt)cff_parse_num( parser, parser->top - 1 );
+ if ( numBlends > parser->stackSize )
+ {
+ FT_ERROR(( "cff_parse_blend: Invalid number of blends\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
FT_TRACE4(( " %d values blended\n", numBlends ));