[truetype] Avoid segfault for invalid variation data. * src/truetype/ttgxvar.c (ft_var_load_item_variation_store): Assure `itemCount' is not zero. Reported as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=441
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
diff --git a/ChangeLog b/ChangeLog
index 862e31e..7409fb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-01-23 Werner Lemberg <wl@gnu.org>
+
+ [truetype] Avoid segfault for invalid variation data.
+
+ * src/truetype/ttgxvar.c (ft_var_load_item_variation_store): Assure
+ `itemCount' is not zero.
+
+ Reported as
+
+ https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=441
+
2017-01-20 Werner Lemberg <wl@gnu.org>
* src/truetype/ttinterp.c (TT_RunIns): Adjust loop detector limits.
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 386c70f..8004206 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -431,7 +431,8 @@
if ( format != 1 )
{
- FT_TRACE2(( "bad store format %d\n", format ));
+ FT_TRACE2(( "ft_var_load_item_variation_store: bad store format %d\n",
+ format ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -441,6 +442,14 @@
FT_READ_USHORT( itemStore->dataCount ) )
goto Exit;
+ /* we need at least one entry in `itemStore->varData' */
+ if ( !itemStore->dataCount )
+ {
+ FT_TRACE2(( "ft_var_load_item_variation_store: missing varData\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
/* make temporary copy of item variation data offsets; */
/* we will parse region list first, then come back */
if ( FT_NEW_ARRAY( dataOffsetArray, itemStore->dataCount ) )