[HB] GDEF sanitize()

This commit is contained in:
Behdad Esfahbod 2009-08-04 14:33:23 -04:00
parent 18939487d0
commit e49a84c9e3
4 changed files with 57 additions and 3 deletions

View File

@ -73,6 +73,10 @@ struct AttachList
return true; return true;
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_THIS2 (coverage, attachPoint);
}
private: private:
OffsetTo<Coverage> OffsetTo<Coverage>
coverage; /* Offset to Coverage table -- from coverage; /* Offset to Coverage table -- from
@ -98,6 +102,10 @@ struct CaretValueFormat1
return context->font->x_scale * coordinate / 0x10000; return context->font->x_scale * coordinate / 0x10000;
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_SELF ();
}
private: private:
USHORT caretValueFormat; /* Format identifier--format = 1 */ USHORT caretValueFormat; /* Format identifier--format = 1 */
SHORT coordinate; /* X or Y value, in design units */ SHORT coordinate; /* X or Y value, in design units */
@ -114,6 +122,10 @@ struct CaretValueFormat2
return /* TODO contour point */ 0; return /* TODO contour point */ 0;
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_SELF ();
}
private: private:
USHORT caretValueFormat; /* Format identifier--format = 2 */ USHORT caretValueFormat; /* Format identifier--format = 2 */
USHORT caretValuePoint; /* Contour point index on glyph */ USHORT caretValuePoint; /* Contour point index on glyph */
@ -131,6 +143,10 @@ struct CaretValueFormat3
((this+deviceTable).get_delta (context->font->x_ppem) << 6); ((this+deviceTable).get_delta (context->font->x_ppem) << 6);
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_SELF () && SANITIZE_THIS (deviceTable);
}
private: private:
USHORT caretValueFormat; /* Format identifier--format = 3 */ USHORT caretValueFormat; /* Format identifier--format = 3 */
SHORT coordinate; /* X or Y value, in design units */ SHORT coordinate; /* X or Y value, in design units */
@ -154,6 +170,16 @@ struct CaretValue
} }
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
if (!SANITIZE (u.format)) return false;
switch (u.format) {
case 1: return u.format1->sanitize (SANITIZE_ARG);
case 2: return u.format2->sanitize (SANITIZE_ARG);
case 3: return u.format3->sanitize (SANITIZE_ARG);
default:return true;
}
}
private: private:
union { union {
USHORT format; /* Format identifier */ USHORT format; /* Format identifier */
@ -179,6 +205,10 @@ struct LigGlyph
*caret_count = carets.len; *caret_count = carets.len;
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE (carets);
}
private: private:
OffsetArrayOf<CaretValue> OffsetArrayOf<CaretValue>
carets; /* Offset rrray of CaretValue tables carets; /* Offset rrray of CaretValue tables
@ -205,6 +235,10 @@ struct LigCaretList
return true; return true;
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_THIS2 (coverage, ligGlyph);
}
private: private:
OffsetTo<Coverage> OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from coverage; /* Offset to Coverage table--from
@ -221,6 +255,10 @@ struct MarkGlyphSetsFormat1
inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
inline bool sanitize (SANITIZE_ARG_DEF) {
return SANITIZE_THIS (coverage);
}
private: private:
USHORT format; /* Format identifier--format = 1 */ USHORT format; /* Format identifier--format = 1 */
LongOffsetArrayOf<Coverage> LongOffsetArrayOf<Coverage>
@ -239,6 +277,14 @@ struct MarkGlyphSets
} }
} }
inline bool sanitize (SANITIZE_ARG_DEF) {
if (!SANITIZE (u.format)) return false;
switch (u.format) {
case 1: return u.format1->sanitize (SANITIZE_ARG);
default:return true;
}
}
private: private:
union { union {
USHORT format; /* Format identifier */ USHORT format; /* Format identifier */
@ -291,6 +337,14 @@ struct GDEF
inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); } { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
bool sanitize (SANITIZE_ARG_DEF) {
if (!SANITIZE (version)) return false;
if (version.major != 1) return true;
return SANITIZE_THIS2 (glyphClassDef, attachList) &&
SANITIZE_THIS2 (ligCaretList, markAttachClassDef) &&
(version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0]));
}
private: private:
FixedVersion version; /* Version of the GDEF table--currently FixedVersion version; /* Version of the GDEF table--currently
* 0x00010002 */ * 0x00010002 */

View File

@ -1501,7 +1501,7 @@ struct GPOS : GSUBGPOS
hb_ot_layout_feature_mask_t mask) const hb_ot_layout_feature_mask_t mask) const
{ return get_lookup (lookup_index).apply_string (context, buffer, mask); } { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
inline bool sanitize (SANITIZE_ARG_DEF) { bool sanitize (SANITIZE_ARG_DEF) {
if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false; if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0); OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);

View File

@ -838,7 +838,7 @@ struct GSUB : GSUBGPOS
{ return get_lookup (lookup_index).apply_string (context, buffer, mask); } { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
inline bool sanitize (SANITIZE_ARG_DEF) { bool sanitize (SANITIZE_ARG_DEF) {
if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false; if (GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0); OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0);
return SANITIZE_THIS (list); return SANITIZE_THIS (list);

View File

@ -848,7 +848,7 @@ struct GSUBGPOS
DEFINE_TAG_FIND_INTERFACE (Script, script ); /* find_script_index (), get_script_by_tag (tag) */ DEFINE_TAG_FIND_INTERFACE (Script, script ); /* find_script_index (), get_script_by_tag (tag) */
DEFINE_TAG_FIND_INTERFACE (Feature, feature); /* find_feature_index(), get_feature_by_tag(tag) */ DEFINE_TAG_FIND_INTERFACE (Feature, feature); /* find_feature_index(), get_feature_by_tag(tag) */
inline bool sanitize (SANITIZE_ARG_DEF) { bool sanitize (SANITIZE_ARG_DEF) {
if (!SANITIZE (version)) return false; if (!SANITIZE (version)) return false;
if (version.major != 1) return true; if (version.major != 1) return true;
return SANITIZE_THIS3 (scriptList, featureList, lookupList); return SANITIZE_THIS3 (scriptList, featureList, lookupList);