[otvalid] Macros for 32bit offset support.

* src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE32,
OTV_OPTIONAL_OFFSET32, OTV_SIZE_CHECK32): New macros.
This commit is contained in:
Werner Lemberg 2017-09-22 07:53:25 +02:00
parent 21c235ecf1
commit 3645982ac2
2 changed files with 38 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2017-09-22 Werner Lemberg <wl@gnu.org>
[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 <apodtele@gmail.com>
[build] Simplify Visual C++ 2010 project.

View File

@ -73,12 +73,21 @@ FT_BEGIN_HEADER
#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; \
_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,12 +111,33 @@ FT_BEGIN_HEADER
" 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
#define OTV_NAME_(x) #x
#define OTV_NAME(x) OTV_NAME_(x)