Hash :
8cd89073
Author :
Date :
2002-05-04T18:02:59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
#include "otlgdef.h"
#include "otlcommn.h"
/************************************************************************/
/************************************************************************/
/***** *****/
/***** ATTACHMENTS LIST *****/
/***** *****/
/************************************************************************/
/************************************************************************/
static void
otl_attach_point_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt count;
if ( p + 2 > valid->limit )
OTL_INVALID_TOO_SHORT;
count = OTL_NEXT_USHORT( p );
if ( table + count*2 > valid->limit )
OTL_INVALID_TOO_SHORT;
}
static void
otl_attach_list_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_Bytes coverage;
OTL_UInt count;
if ( p + 4 > valid->limit )
OTL_INVALID_TOO_SHORT;
coverage = table + OTL_NEXT_USHORT( p );
count = OTL_NEXT_USHORT( p );
otl_coverage_validate( coverage, valid );
if ( count != otl_coverage_get_count( coverage ) )
OTL_INVALID_DATA;
if ( p + count*2 > valid->limit )
OTL_INVALID_TOO_SHORT;
for ( ; count > 0; count-- )
otl_attach_point_validate( table + OTL_NEXT_USHORT( p ) );
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** LIGATURE CARETS *****/
/***** *****/
/************************************************************************/
/************************************************************************/
static void
otl_caret_value_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
if ( p + 4 > valid->limit )
OTL_INVALID_TOO_SHORT;
format = OTL_NEXT_USHORT( p );
switch ( format )
{
case 1:
case 2:
break;
case 3:
{
OTL_Bytes device;
p += 2;
if ( p + 2 > valid->limit )
OTL_INVALID_TOO_SHORT;
otl_device_table_validate( table + OTL_PEEK_USHORT( p ) );
}
break;
default:
OTL_INVALID_DATA;
}
}
static void
otl_ligature_glyph_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_UInt count;
if ( p + 2 > valid->limit )
OTL_INVALID_TOO_SHORT;
count = OTL_NEXT_USHORT( p );
if ( p + count*2 > valid->limit )
OTL_INVALID_TOO_SHORT;
for ( ; count > 0; count-- )
otl_caret_value_validate( table + OTL_NEXT_USHORT( p ) );
}
static void
otl_ligature_caret_list_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
OTL_Bytes coverage;
OTL_UInt count;
if ( p + 4 > valid->limit )
OTL_INVALID_TOO_SHORT;
coverage = table + OTL_NEXT_USHORT( p );
count = OTL_NEXT_USHORT( p );
otl_coverage_validate( coverage, valid );
if ( count != otl_coverage_get_count( coverage ) )
OTL_INVALID_DATA;
if ( p + count*2 > valid->limit )
OTL_INVALID_TOO_SHORT;
for ( ; count > 0; count-- )
otl_ligature_glyph_validate( table + OTL_NEXT_USHORT( p ) );
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** GDEF TABLE *****/
/***** *****/
/************************************************************************/
/************************************************************************/
OTL_APIDEF( void )
otl_gdef_validate( OTL_Bytes table,
OTL_Validator valid )
{
OTL_Bytes p = table;
if ( p + 12 > valid->limit )
OTL_INVALID_TOO_SHORT;
/* check format */
if ( OTL_NEXT_ULONG( p ) != 0x00010000UL )
OTL_INVALID_FORMAT;
/* validate class definition table */
otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) );
/* validate attachment point list */
otl_attach_list_validate( table + OTL_NEXT_USHORT( p ) );
/* validate ligature caret list */
otl_ligature_caret_list_validate( table + OTL_NEXT_USHORT( p ) );
/* validate mark attach class */
otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) );
}