Commit 2b79d25f2213aef0e3dc66f0e7f973fccede9c12

Werner Lemberg 2017-09-23T10:29:26

[otvalid] Update common table handling to OpenType 1.8.2. * src/otvalid/otvcommn.c (otv_Device_validate): Handle VariationIndex subtable. (otv_Lookup_validate): Handle MarkFilteringSet.

diff --git a/ChangeLog b/ChangeLog
index 4a04e8b..cf57a70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,14 @@
 	* build/windows/ftver.rc: New VERSIONINFO resource.
 	* build/windows/vc2010/freetype.vcxproj: Further improvements.
 
+2017-09-23  Werner Lemberg  <wl@gnu.org>
+
+	[otvalid] Update common table handling to OpenType 1.8.2.
+
+	* src/otvalid/otvcommn.c (otv_Device_validate): Handle
+	VariationIndex subtable.
+	(otv_Lookup_validate): Handle MarkFilteringSet.
+
 2017-09-23  Ben Wagner  <bungeman@google.com>
 
 	[truetype] Really fix #52082.
diff --git a/src/otvalid/otvcommn.c b/src/otvalid/otvcommn.c
index 3407d2a..0583620 100644
--- a/src/otvalid/otvcommn.c
+++ b/src/otvalid/otvcommn.c
@@ -313,19 +313,26 @@
 
     OTV_NAME_ENTER( "Device" );
 
-    OTV_LIMIT_CHECK( 8 );
+    OTV_LIMIT_CHECK( 6 );
     StartSize   = FT_NEXT_USHORT( p );
     EndSize     = FT_NEXT_USHORT( p );
     DeltaFormat = FT_NEXT_USHORT( p );
 
-    if ( DeltaFormat < 1 || DeltaFormat > 3 )
-      FT_INVALID_FORMAT;
+    if ( DeltaFormat == 0x8000U )
+    {
+      /* VariationIndex, nothing to do */
+    }
+    else
+    {
+      if ( DeltaFormat < 1 || DeltaFormat > 3 )
+        FT_INVALID_FORMAT;
 
-    if ( EndSize < StartSize )
-      FT_INVALID_DATA;
+      if ( EndSize < StartSize )
+        FT_INVALID_DATA;
 
-    count = EndSize - StartSize + 1;
-    OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 );  /* DeltaValue */
+      count = EndSize - StartSize + 1;
+      OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 );  /* DeltaValue */
+    }
 
     OTV_EXIT;
   }
@@ -347,7 +354,7 @@
                        OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
-    FT_UInt            LookupType, SubTableCount;
+    FT_UInt            LookupType, LookupFlag, SubTableCount;
     OTV_Validate_Func  validate;
 
 
@@ -355,7 +362,7 @@
 
     OTV_LIMIT_CHECK( 6 );
     LookupType    = FT_NEXT_USHORT( p );
-    p            += 2;                      /* skip LookupFlag */
+    LookupFlag    = FT_NEXT_USHORT( p );
     SubTableCount = FT_NEXT_USHORT( p );
 
     OTV_TRACE(( " (type %d)\n", LookupType ));
@@ -373,6 +380,9 @@
     for ( ; SubTableCount > 0; SubTableCount-- )
       validate( table + FT_NEXT_USHORT( p ), otvalid );
 
+    if ( LookupFlag & 0x10 )
+      OTV_LIMIT_CHECK( 2 );  /* MarkFilteringSet */
+
     OTV_EXIT;
   }