shithub: freetype+ttf2subf

Download patch

ref: 3645982ac26c7a99bf77a3af2bf7eb6a3f871334
parent: 21c235ecf1383c408dc115c00eb95800c88d9f10
author: Werner Lemberg <[email protected]>
date: Fri Sep 22 03:53:25 EDT 2017

[otvalid] Macros for 32bit offset support.

* src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE32,
OTV_OPTIONAL_OFFSET32, OTV_SIZE_CHECK32): New macros.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-09-22  Werner Lemberg  <[email protected]>
+
+	[otvalid] Macros for 32bit offset support.
+
+	* src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE32,
+	OTV_OPTIONAL_OFFSET32, OTV_SIZE_CHECK32): New macros.
+
 2017-09-21  Alexei Podtelezhnikov  <[email protected]>
 
 	[build] Simplify Visual C++ 2010 project.
--- a/src/otvalid/otvcommn.h
+++ b/src/otvalid/otvcommn.h
@@ -73,6 +73,9 @@
 #define OTV_OPTIONAL_TABLE( _table )  FT_UShort  _table;      \
                                       FT_Bytes   _table ## _p
 
+#define OTV_OPTIONAL_TABLE32( _table )  FT_ULong  _table;       \
+                                        FT_Bytes   _table ## _p
+
 #define OTV_OPTIONAL_OFFSET( _offset )           \
           FT_BEGIN_STMNT                         \
             _offset ## _p = p;                   \
@@ -79,6 +82,12 @@
             _offset       = FT_NEXT_USHORT( p ); \
           FT_END_STMNT
 
+#define OTV_OPTIONAL_OFFSET32( _offset )        \
+          FT_BEGIN_STMNT                        \
+            _offset ## _p = p;                  \
+            _offset       = FT_NEXT_ULONG( p ); \
+          FT_END_STMNT
+
 #define OTV_LIMIT_CHECK( _count )                      \
           FT_BEGIN_STMNT                               \
             if ( p + (_count) > otvalid->root->limit ) \
@@ -102,8 +111,29 @@
                             " set to zero.\n"                       \
                             "\n", #_size ));                        \
                                                                     \
-                /* always assume 16bit entities */                  \
                 _size = pp[0] = pp[1] = 0;                          \
+              }                                                     \
+            }                                                       \
+          FT_END_STMNT
+
+#define OTV_SIZE_CHECK32( _size )                                   \
+          FT_BEGIN_STMNT                                            \
+            if ( _size > 0 && _size < table_size )                  \
+            {                                                       \
+              if ( otvalid->root->level == FT_VALIDATE_PARANOID )   \
+                FT_INVALID_OFFSET;                                  \
+              else                                                  \
+              {                                                     \
+                /* strip off `const' */                             \
+                FT_Byte*  pp = (FT_Byte*)_size ## _p;               \
+                                                                    \
+                                                                    \
+                FT_TRACE3(( "\n"                                    \
+                            "Invalid offset to optional table `%s'" \
+                            " set to zero.\n"                       \
+                            "\n", #_size ));                        \
+                                                                    \
+                _size = pp[0] = pp[1] = pp[2] = pp[3] = 0;          \
               }                                                     \
             }                                                       \
           FT_END_STMNT