shithub: freetype+ttf2subf

Download patch

ref: 79d52b9a8d1422587ea4d74ce761fb211b55cd3f
parent: 15c6e8d6c550f96e6520689bb6a4b2b8d16bbdd3
author: Werner Lemberg <[email protected]>
date: Mon Jan 23 02:43:56 EST 2017

[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

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-01-23  Werner Lemberg  <[email protected]>
+
+	[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  <[email protected]>
 
 	* src/truetype/ttinterp.c (TT_RunIns): Adjust loop detector limits.
--- 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;
     }
@@ -440,6 +441,14 @@
     if ( FT_READ_ULONG( region_offset )         ||
          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     */