[gxvalid] Fix gcc4.6 compiler warnings in gxvmorx*.c. * src/gxvalid/gxvmorx.c (gxv_morx_subtables_validate): Conditionalize unvalidated variable `subFeatureFlags'. (gxv_morx_chain_validate): Conditionalize unvalidated variable `defaultFlags'. * src/gxvalid/gxmorx0.c (gxv_morx_subtable_type0_entry_validate): Conditionalize unvalidated variables; `markFirst', `dontAdvance', `markLast', `verb'. * src/gxvalid/gxmorx1.c (gxv_morx_subtable_type1_entry_validate): Conditionalize unvalidated variables; `setMark', `dontAdvance'. * src/gxvalid/gxvmorx2.c (gxv_morx_subtable_type2_ligActionOffset_validate): Conditionalize unvalidated variables; `last', `store'. Checking for overrunning offset is added. (gxv_morx_subtable_type2_entry_validate): Conditionalize unvalidated variables; `setComponent', `dontAdvance', `performAction'. (gxv_morx_subtable_type2_ligatureTable_validate): Check if the GID for ligature does not exceed the max GID in `maxp' table. * src/gxvalid/gxvmort5.c (gxv_morx_subtable_type5_InsertList_validate): Conditionalize unvalidated loading of `insert_glyphID' array. (gxv_morx_subtable_type5_entry_validate): Conditionalize unvalidated variables; `setMark', `dontAdvance', `currentIsKashidaLike', `markedIsKashidaLike', `currentInsertBefore', `markedInsertBefore'.
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
diff --git a/ChangeLog b/ChangeLog
index fdc8c42..5a69430 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,43 @@
2011-06-14 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ [gxvalid] Fix gcc4.6 compiler warnings in gxvmorx*.c.
+
+ * src/gxvalid/gxvmorx.c (gxv_morx_subtables_validate):
+ Conditionalize unvalidated variable `subFeatureFlags'.
+ (gxv_morx_chain_validate): Conditionalize unvalidated
+ variable `defaultFlags'.
+
+ * src/gxvalid/gxmorx0.c
+ (gxv_morx_subtable_type0_entry_validate):
+ Conditionalize unvalidated variables; `markFirst',
+ `dontAdvance', `markLast', `verb'.
+
+ * src/gxvalid/gxmorx1.c
+ (gxv_morx_subtable_type1_entry_validate): Conditionalize
+ unvalidated variables; `setMark', `dontAdvance'.
+
+ * src/gxvalid/gxvmorx2.c
+ (gxv_morx_subtable_type2_ligActionOffset_validate):
+ Conditionalize unvalidated variables; `last', `store'.
+ Checking for overrunning offset is added.
+ (gxv_morx_subtable_type2_entry_validate):
+ Conditionalize unvalidated variables; `setComponent',
+ `dontAdvance', `performAction'.
+ (gxv_morx_subtable_type2_ligatureTable_validate):
+ Check if the GID for ligature does not exceed the
+ max GID in `maxp' table.
+
+ * src/gxvalid/gxvmort5.c
+ (gxv_morx_subtable_type5_InsertList_validate):
+ Conditionalize unvalidated loading of `insert_glyphID'
+ array. (gxv_morx_subtable_type5_entry_validate):
+ Conditionalize unvalidated variables; `setMark',
+ `dontAdvance', `currentIsKashidaLike',
+ `markedIsKashidaLike', `currentInsertBefore',
+ `markedInsertBefore'.
+
+2011-06-14 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
[gxvalid] Fix gcc4.6 compiler warnings in gxvmort*.c.
* src/gxvalid/gxvmort.c (gxv_mort_subtables_validate):
diff --git a/src/gxvalid/gxvmorx.c b/src/gxvalid/gxvmorx.c
index f8ba5b9..4b1dd00 100644
--- a/src/gxvalid/gxvmorx.c
+++ b/src/gxvalid/gxvmorx.c
@@ -68,7 +68,9 @@
{
FT_ULong length;
FT_ULong coverage;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong subFeatureFlags;
+#endif
FT_ULong type;
FT_ULong rest;
@@ -76,7 +78,11 @@
GXV_LIMIT_CHECK( 4 + 4 + 4 );
length = FT_NEXT_ULONG( p );
coverage = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
subFeatureFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
GXV_TRACE(( "validating chain subtable %d/%d (%d bytes)\n",
i + 1, nSubtables, length ));
@@ -97,6 +103,7 @@
func( p, p + rest, valid );
+ /* TODO: subFeatureFlags should be unique in a table? */
p += rest;
}
@@ -112,7 +119,9 @@
GXV_Validator valid )
{
FT_Bytes p = table;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_ULong defaultFlags;
+#endif
FT_ULong chainLength;
FT_ULong nFeatureFlags;
FT_ULong nSubtables;
@@ -121,7 +130,11 @@
GXV_NAME_ENTER( "morx chain header" );
GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
+#ifdef GXV_LOAD_UNUSED_VARS
defaultFlags = FT_NEXT_ULONG( p );
+#else
+ p += 4;
+#endif
chainLength = FT_NEXT_ULONG( p );
nFeatureFlags = FT_NEXT_ULONG( p );
nSubtables = FT_NEXT_ULONG( p );
@@ -138,6 +151,8 @@
valid->subtable_length = chainLength;
+ /* TODO: defaultFlags should be compared with the flags in tables */
+
GXV_EXIT;
}
diff --git a/src/gxvalid/gxvmorx0.c b/src/gxvalid/gxvmorx0.c
index 0159c5a..6a736c1 100644
--- a/src/gxvalid/gxvmorx0.c
+++ b/src/gxvalid/gxvmorx0.c
@@ -47,11 +47,15 @@
FT_Bytes limit,
GXV_Validator valid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort markFirst;
FT_UShort dontAdvance;
FT_UShort markLast;
+#endif
FT_UShort reserved;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort verb;
+#endif
FT_UNUSED( state );
FT_UNUSED( glyphOffset_p );
@@ -59,12 +63,16 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
markFirst = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
markLast = (FT_UShort)( ( flags >> 13 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x1FF0 );
+#ifdef GXV_LOAD_UNUSED_VARS
verb = (FT_UShort)( flags & 0x000F );
+#endif
if ( 0 < reserved )
{
diff --git a/src/gxvalid/gxvmorx1.c b/src/gxvalid/gxvmorx1.c
index e1c162f..337e297 100644
--- a/src/gxvalid/gxvmorx1.c
+++ b/src/gxvalid/gxvmorx1.c
@@ -108,8 +108,10 @@
FT_Bytes limit,
GXV_Validator valid )
{
+#ifdef GXV_LOAD_TRACE_VARS
FT_UShort setMark;
FT_UShort dontAdvance;
+#endif
FT_UShort reserved;
FT_Short markIndex;
FT_Short currentIndex;
@@ -122,8 +124,10 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_TRACE_VARS
setMark = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x3FFF );
diff --git a/src/gxvalid/gxvmorx2.c b/src/gxvalid/gxvmorx2.c
index b4bb335..feec66c 100644
--- a/src/gxvalid/gxvmorx2.c
+++ b/src/gxvalid/gxvmorx2.c
@@ -168,16 +168,53 @@
{
/* validate entry in ligActionTable */
FT_ULong lig_action;
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort last;
FT_UShort store;
+#endif
FT_ULong offset;
lig_action = FT_NEXT_ULONG( p );
+#ifdef GXV_LOAD_UNUSED_VARS
last = (FT_UShort)( ( lig_action >> 31 ) & 1 );
store = (FT_UShort)( ( lig_action >> 30 ) & 1 );
+#endif
offset = lig_action & 0x3FFFFFFFUL;
+
+ /* this offset is 30-bit signed value to add to GID */
+ /* it is different from the location offset in mort */
+ if ( ( offset & 0x3FFF0000UL ) == 0x3FFF0000UL )
+ {
+ if ( offset + valid->face->num_glyphs > 0x40000000UL )
+ return;
+
+ GXV_TRACE(( "ligature action table includes"
+ " too negative offset moving all GID"
+ " below defined range: 0x%04x\n",
+ offset & 0xFFFFU ));
+ if ( valid->root->level >= FT_VALIDATE_PARANOID )
+ FT_INVALID_OFFSET;
+ }
+ else if ( ( offset & 0x3FFF0000UL ) == 0x0000000UL )
+ {
+ if ( offset + valid->face->num_glyphs < 0 )
+ return;
+
+ GXV_TRACE(( "ligature action table includes"
+ " too large offset moving all GID"
+ " over defined range: 0x%04x\n",
+ offset & 0xFFFFU ));
+ if ( valid->root->level >= FT_VALIDATE_PARANOID )
+ FT_INVALID_OFFSET;
+ }
+
+ GXV_TRACE(( "ligature action table includes"
+ " invalid offset to add to 16-bit GID:"
+ " 0x%08x\n", offset ));
+ if ( valid->root->level >= FT_VALIDATE_PARANOID )
+ FT_INVALID_OFFSET;
}
}
@@ -191,9 +228,11 @@
FT_Bytes limit,
GXV_Validator valid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_UShort setComponent;
FT_UShort dontAdvance;
FT_UShort performAction;
+#endif
FT_UShort reserved;
FT_UShort ligActionIndex;
@@ -201,9 +240,11 @@
FT_UNUSED( limit );
+#ifdef GXV_LOAD_UNUSED_VARS
setComponent = (FT_UShort)( ( flags >> 15 ) & 1 );
dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
performAction = (FT_UShort)( ( flags >> 13 ) & 1 );
+#endif
reserved = (FT_UShort)( flags & 0x1FFF );
ligActionIndex = glyphOffset_p->u;
@@ -241,6 +282,9 @@
GXV_LIMIT_CHECK( 2 );
lig_gid = FT_NEXT_USHORT( p );
+ if ( valid->root->level >= FT_VALIDATE_PARANOID &&
+ lig_gid < valid->face->num_glyphs )
+ FT_INVALID_GLYPH_ID;
}
}
diff --git a/src/gxvalid/gxvmorx5.c b/src/gxvalid/gxvmorx5.c
index 5e3a164..d8cf700 100644
--- a/src/gxvalid/gxvmorx5.c
+++ b/src/gxvalid/gxvmorx5.c
@@ -118,6 +118,9 @@
FT_Bytes p = table + table_index * 2;
+#ifndef GXV_LOAD_TRACE_VARS
+ GXV_LIMIT_CHECK( count * 2 );
+#else
while ( p < table + count * 2 + table_index * 2 )
{
FT_UShort insert_glyphID;
@@ -129,6 +132,7 @@
}
GXV_TRACE(( "\n" ));
+#endif
}
@@ -141,12 +145,14 @@
FT_Bytes limit,
GXV_Validator valid )
{
+#ifdef GXV_LOAD_UNUSED_VARS
FT_Bool setMark;
FT_Bool dontAdvance;
FT_Bool currentIsKashidaLike;
FT_Bool markedIsKashidaLike;
FT_Bool currentInsertBefore;
FT_Bool markedInsertBefore;
+#endif
FT_Byte currentInsertCount;
FT_Byte markedInsertCount;
FT_Byte currentInsertList;
@@ -155,12 +161,14 @@
FT_UNUSED( state );
+#ifdef GXV_LOAD_UNUSED_VARS
setMark = FT_BOOL( ( flags >> 15 ) & 1 );
dontAdvance = FT_BOOL( ( flags >> 14 ) & 1 );
currentIsKashidaLike = FT_BOOL( ( flags >> 13 ) & 1 );
markedIsKashidaLike = FT_BOOL( ( flags >> 12 ) & 1 );
currentInsertBefore = FT_BOOL( ( flags >> 11 ) & 1 );
markedInsertBefore = FT_BOOL( ( flags >> 10 ) & 1 );
+#endif
currentInsertCount = (FT_Byte)( ( flags >> 5 ) & 0x1F );
markedInsertCount = (FT_Byte)( flags & 0x001F );