Commit 0b3cb8a8afb15247ee55477f73e25e0ca3038e5b

Werner Lemberg 2016-05-05T12:28:48

[cff, truetype] Fix logic for `FT_Property_Set'. Otherwise some properties could be set to arbitrary values, which is harmless, but querying could give wrong positive results. * src/cff/cffdrivr.c (cff_property_set) [hinting-engine], * src/truetype/ttdriver.c (tt_property_set) [interpreter-version]: Only allow defined values.

diff --git a/ChangeLog b/ChangeLog
index c329253..c5f7da7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2016-05-05  Werner Lemberg  <wl@gnu.org>
+
+	[cff, truetype] Fix logic for `FT_Property_Set'.
+
+	Otherwise some properties could be set to arbitrary values, which is
+	harmless, but querying could give wrong positive results.
+
+	* src/cff/cffdrivr.c (cff_property_set) [hinting-engine],
+	* src/truetype/ttdriver.c (tt_property_set) [interpreter-version]:
+	Only allow defined values.
+
 2016-04-25  Werner Lemberg  <wl@gnu.org>
 
 	[autofit] Add blue-zone support for Gujarati script.
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 7a82094..950a960 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -701,12 +701,14 @@
       FT_UInt*  hinting_engine = (FT_UInt*)value;
 
 
-#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
-      if ( *hinting_engine != FT_CFF_HINTING_ADOBE )
-        error = FT_ERR( Unimplemented_Feature );
-      else
+      if ( *hinting_engine == FT_CFF_HINTING_ADOBE
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+           || *hinting_engine == FT_CFF_HINTING_FREETYPE
 #endif
+         )
         driver->hinting_engine = *hinting_engine;
+      else
+        error = FT_ERR( Unimplemented_Feature );
 
       return error;
     }
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index bbebabd..abbd127 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -72,12 +72,14 @@
       FT_UInt*  interpreter_version = (FT_UInt*)value;
 
 
-#ifndef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-      if ( *interpreter_version != TT_INTERPRETER_VERSION_35 )
-        error = FT_ERR( Unimplemented_Feature );
-      else
+      if ( *interpreter_version == TT_INTERPRETER_VERSION_35
+#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+           || *interpreter_version == TT_INTERPRETER_VERSION_38
 #endif
+         )
         driver->interpreter_version = *interpreter_version;
+      else
+        error = FT_ERR( Unimplemented_Feature );
 
       return error;
     }