ReactOS  0.4.15-dev-2701-g34593d9
gxvtrak.c File Reference
#include "gxvalid.h"
#include "gxvcommn.h"
Include dependency graph for gxvtrak.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GXV_trak_DataRec_
 

Macros

#define FT_COMPONENT   trace_gxvtrak
 
#define GXV_TRAK_DATA(FIELD)   GXV_TABLE_DATA( trak, FIELD )
 

Typedefs

typedef struct GXV_trak_DataRec_ GXV_trak_DataRec
 
typedef struct GXV_trak_DataRec_GXV_trak_Data
 

Functions

static void gxv_trak_trackTable_validate (FT_Bytes table, FT_Bytes limit, FT_UShort nTracks, GXV_Validator gxvalid)
 
static void gxv_trak_trackData_validate (FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
 
 gxv_trak_validate (FT_Bytes table, FT_Face face, FT_Validator ftvalid)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_gxvtrak

Definition at line 39 of file gxvtrak.c.

◆ GXV_TRAK_DATA

#define GXV_TRAK_DATA (   FIELD)    GXV_TABLE_DATA( trak, FIELD )

Definition at line 82 of file gxvtrak.c.

Typedef Documentation

◆ GXV_trak_Data

◆ GXV_trak_DataRec

Function Documentation

◆ gxv_trak_trackData_validate()

static void gxv_trak_trackData_validate ( FT_Bytes  table,
FT_Bytes  limit,
GXV_Validator  gxvalid 
)
static

Definition at line 144 of file gxvtrak.c.

147  {
148  FT_Bytes p = table;
149  FT_UShort nTracks;
150  FT_UShort nSizes;
151  FT_ULong sizeTableOffset;
152 
153  GXV_ODTECT( 4, odtect );
154 
155 
156  GXV_ODTECT_INIT( odtect );
157  GXV_NAME_ENTER( "trackData" );
158 
159  /* read the header of trackData */
160  GXV_LIMIT_CHECK( 2 + 2 + 4 );
161  nTracks = FT_NEXT_USHORT( p );
162  nSizes = FT_NEXT_USHORT( p );
163  sizeTableOffset = FT_NEXT_ULONG( p );
164 
166  "trackData header", odtect );
167 
168  /* validate trackTable */
169  gxv_trak_trackTable_validate( p, limit, nTracks, gxvalid );
171  "trackTable", odtect );
172 
173  /* sizeTable is array of FT_Fixed, don't check contents */
174  p = gxvalid->root->base + sizeTableOffset;
175  GXV_LIMIT_CHECK( nSizes * 4 );
176  gxv_odtect_add_range( p, nSizes * 4, "sizeTable", odtect );
177 
178  /* validate trackValueOffet */
179  p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
180  if ( limit - p < nTracks * nSizes * 2 )
181  GXV_TRACE(( "too short trackValue array\n" ));
182 
183  p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
184  GXV_LIMIT_CHECK( nSizes * 2 );
185 
186  gxv_odtect_add_range( gxvalid->root->base
187  + GXV_TRAK_DATA( trackValueOffset_min ),
188  GXV_TRAK_DATA( trackValueOffset_max )
189  - GXV_TRAK_DATA( trackValueOffset_min )
190  + nSizes * 2,
191  "trackValue array", odtect );
192 
193  gxv_odtect_validate( odtect, gxvalid );
194 
195  GXV_EXIT;
196  }
unsigned long FT_ULong
Definition: fttypes.h:253
static void gxv_trak_trackTable_validate(FT_Bytes table, FT_Bytes limit, FT_UShort nTracks, GXV_Validator gxvalid)
Definition: gxvtrak.c:94
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
#define GXV_TRACE(s)
Definition: gxvcommn.h:304
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define GXV_ODTECT(n, odtect)
Definition: gxvcommn.h:562
GLint limit
Definition: glext.h:10326
gxv_odtect_validate(GXV_odtect_Range odtect, GXV_Validator gxvalid)
Definition: gxvcommn.c:1715
#define GXV_EXIT
Definition: gxvcommn.h:302
FT_Validator root
Definition: gxvcommn.h:239
#define GXV_ODTECT_INIT(odtect)
Definition: gxvcommn.h:567
const FT_Byte * FT_Bytes
Definition: fttypes.h:165
#define GXV_TRAK_DATA(FIELD)
Definition: gxvtrak.c:82
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:238
FT_ULong subtable_length
Definition: gxvcommn.h:244
gxv_odtect_add_range(FT_Bytes start, FT_ULong length, const FT_String *name, GXV_odtect_Range odtect)
Definition: gxvcommn.c:1702
GLfloat GLfloat p
Definition: glext.h:8902
unsigned short FT_UShort
Definition: fttypes.h:209
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272

Referenced by gxv_trak_validate().

◆ gxv_trak_trackTable_validate()

static void gxv_trak_trackTable_validate ( FT_Bytes  table,
FT_Bytes  limit,
FT_UShort  nTracks,
GXV_Validator  gxvalid 
)
static

Definition at line 94 of file gxvtrak.c.

98  {
99  FT_Bytes p = table;
100 
101  FT_Fixed track, t;
102  FT_UShort nameIndex;
104  FT_UShort i, j;
105 
106 
107  GXV_NAME_ENTER( "trackTable" );
108 
109  GXV_TRAK_DATA( trackValueOffset_min ) = 0xFFFFU;
110  GXV_TRAK_DATA( trackValueOffset_max ) = 0x0000;
111 
112  GXV_LIMIT_CHECK( nTracks * ( 4 + 2 + 2 ) );
113 
114  for ( i = 0; i < nTracks; i++ )
115  {
116  p = table + i * ( 4 + 2 + 2 );
117  track = FT_NEXT_LONG( p );
118  nameIndex = FT_NEXT_USHORT( p );
119  offset = FT_NEXT_USHORT( p );
120 
121  if ( offset < GXV_TRAK_DATA( trackValueOffset_min ) )
122  GXV_TRAK_DATA( trackValueOffset_min ) = offset;
123  if ( offset > GXV_TRAK_DATA( trackValueOffset_max ) )
124  GXV_TRAK_DATA( trackValueOffset_max ) = offset;
125 
126  gxv_sfntName_validate( nameIndex, 256, 32767, gxvalid );
127 
128  for ( j = i; j < nTracks; j++ )
129  {
130  p = table + j * ( 4 + 2 + 2 );
131  t = FT_NEXT_LONG( p );
132  if ( t == track )
133  GXV_TRACE(( "duplicated entries found for track value 0x%x\n",
134  track ));
135  }
136  }
137 
138  gxvalid->subtable_length = (FT_ULong)( p - table );
139  GXV_EXIT;
140  }
unsigned long FT_ULong
Definition: fttypes.h:253
#define FT_NEXT_LONG(buffer)
Definition: ftstream.h:235
#define GXV_NAME_ENTER(name)
Definition: gxvcommn.h:301
#define GXV_TRACE(s)
Definition: gxvcommn.h:304
#define U(x)
Definition: wordpad.c:45
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
gxv_sfntName_validate(FT_UShort name_index, FT_UShort min_index, FT_UShort max_index, GXV_Validator gxvalid)
Definition: gxvcommn.c:884
#define GXV_EXIT
Definition: gxvcommn.h:302
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLintptr offset
Definition: glext.h:5920
const FT_Byte * FT_Bytes
Definition: fttypes.h:165
#define GXV_TRAK_DATA(FIELD)
Definition: gxvtrak.c:82
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
signed long FT_Fixed
Definition: fttypes.h:288
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FT_ULong subtable_length
Definition: gxvcommn.h:244
GLfloat GLfloat p
Definition: glext.h:8902
unsigned short FT_UShort
Definition: fttypes.h:209
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272

Referenced by gxv_trak_trackData_validate().

◆ gxv_trak_validate()

gxv_trak_validate ( FT_Bytes  table,
FT_Face  face,
FT_Validator  ftvalid 
)

Definition at line 208 of file gxvtrak.c.

211  {
212  FT_Bytes p = table;
213  FT_Bytes limit = 0;
214 
215  GXV_ValidatorRec gxvalidrec;
216  GXV_Validator gxvalid = &gxvalidrec;
217  GXV_trak_DataRec trakrec;
218  GXV_trak_Data trak = &trakrec;
219 
222  FT_UShort horizOffset;
223  FT_UShort vertOffset;
225 
226 
227  GXV_ODTECT( 3, odtect );
228 
229  GXV_ODTECT_INIT( odtect );
230  gxvalid->root = ftvalid;
231  gxvalid->table_data = trak;
232  gxvalid->face = face;
233 
234  limit = gxvalid->root->limit;
235 
236  FT_TRACE3(( "validating `trak' table\n" ));
237  GXV_INIT;
238 
239  GXV_LIMIT_CHECK( 4 + 2 + 2 + 2 + 2 );
240  version = FT_NEXT_ULONG( p );
241  format = FT_NEXT_USHORT( p );
242  horizOffset = FT_NEXT_USHORT( p );
243  vertOffset = FT_NEXT_USHORT( p );
245 
246  GXV_TRACE(( " (version = 0x%08x)\n", version ));
247  GXV_TRACE(( " (format = 0x%04x)\n", format ));
248  GXV_TRACE(( " (horizOffset = 0x%04x)\n", horizOffset ));
249  GXV_TRACE(( " (vertOffset = 0x%04x)\n", vertOffset ));
250  GXV_TRACE(( " (reserved = 0x%04x)\n", reserved ));
251 
252  /* Version 1.0 (always:1996) */
253  if ( version != 0x00010000UL )
255 
256  /* format 0 (always:1996) */
257  if ( format != 0x0000 )
259 
260  GXV_32BIT_ALIGNMENT_VALIDATE( horizOffset );
261  GXV_32BIT_ALIGNMENT_VALIDATE( vertOffset );
262 
263  /* Reserved Fixed Value (always) */
264  if ( reserved != 0x0000 )
266 
267  /* validate trackData */
268  if ( 0 < horizOffset )
269  {
270  gxv_trak_trackData_validate( table + horizOffset, limit, gxvalid );
271  gxv_odtect_add_range( table + horizOffset, gxvalid->subtable_length,
272  "horizJustData", odtect );
273  }
274 
275  if ( 0 < vertOffset )
276  {
277  gxv_trak_trackData_validate( table + vertOffset, limit, gxvalid );
278  gxv_odtect_add_range( table + vertOffset, gxvalid->subtable_length,
279  "vertJustData", odtect );
280  }
281 
282  gxv_odtect_validate( odtect, gxvalid );
283 
284  FT_TRACE4(( "\n" ));
285  }
unsigned long FT_ULong
Definition: fttypes.h:253
#define FT_INVALID_FORMAT
Definition: ftvalid.h:142
#define GXV_TRACE(s)
Definition: gxvcommn.h:304
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define GXV_ODTECT(n, odtect)
Definition: gxvcommn.h:562
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLint limit
Definition: glext.h:10326
gxv_odtect_validate(GXV_odtect_Range odtect, GXV_Validator gxvalid)
Definition: gxvcommn.c:1715
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
r reserved
Definition: btrfs.c:2940
void * table_data
Definition: gxvcommn.h:242
static const WCHAR version[]
Definition: asmname.c:66
FT_Validator root
Definition: gxvcommn.h:239
#define GXV_32BIT_ALIGNMENT_VALIDATE(a)
Definition: gxvcommn.h:317
WORD face[3]
Definition: mesh.c:4747
#define GXV_ODTECT_INIT(odtect)
Definition: gxvcommn.h:567
const FT_Byte * FT_Bytes
Definition: fttypes.h:165
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
static void gxv_trak_trackData_validate(FT_Bytes table, FT_Bytes limit, GXV_Validator gxvalid)
Definition: gxvtrak.c:144
#define FT_TRACE3(varformat)
Definition: ftdebug.h:160
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:238
#define FT_INVALID_DATA
Definition: ftvalid.h:150
FT_ULong subtable_length
Definition: gxvcommn.h:244
gxv_odtect_add_range(FT_Bytes start, FT_ULong length, const FT_String *name, GXV_odtect_Range odtect)
Definition: gxvcommn.c:1702
GLfloat GLfloat p
Definition: glext.h:8902
unsigned short FT_UShort
Definition: fttypes.h:209
#define GXV_INIT
Definition: gxvcommn.h:300
#define GXV_LIMIT_CHECK(_count)
Definition: gxvcommn.h:272