From e49a84c9e37c08808880e74e94c8160731ababa1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 Aug 2009 14:33:23 -0400 Subject: [PATCH] [HB] GDEF sanitize() --- src/hb-ot-layout-gdef-private.hh | 54 ++++++++++++++++++++++++++++ src/hb-ot-layout-gpos-private.hh | 2 +- src/hb-ot-layout-gsub-private.hh | 2 +- src/hb-ot-layout-gsubgpos-private.hh | 2 +- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index 97d124ed2..2a96a6487 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh @@ -73,6 +73,10 @@ struct AttachList return true; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_THIS2 (coverage, attachPoint); + } + private: OffsetTo coverage; /* Offset to Coverage table -- from @@ -98,6 +102,10 @@ struct CaretValueFormat1 return context->font->x_scale * coordinate / 0x10000; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_SELF (); + } + private: USHORT caretValueFormat; /* Format identifier--format = 1 */ SHORT coordinate; /* X or Y value, in design units */ @@ -114,6 +122,10 @@ struct CaretValueFormat2 return /* TODO contour point */ 0; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_SELF (); + } + private: USHORT caretValueFormat; /* Format identifier--format = 2 */ USHORT caretValuePoint; /* Contour point index on glyph */ @@ -131,6 +143,10 @@ struct CaretValueFormat3 ((this+deviceTable).get_delta (context->font->x_ppem) << 6); } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_SELF () && SANITIZE_THIS (deviceTable); + } + private: USHORT caretValueFormat; /* Format identifier--format = 3 */ 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: union { USHORT format; /* Format identifier */ @@ -179,6 +205,10 @@ struct LigGlyph *caret_count = carets.len; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE (carets); + } + private: OffsetArrayOf carets; /* Offset rrray of CaretValue tables @@ -205,6 +235,10 @@ struct LigCaretList return true; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_THIS2 (coverage, ligGlyph); + } + private: OffsetTo 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 { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } + inline bool sanitize (SANITIZE_ARG_DEF) { + return SANITIZE_THIS (coverage); + } + private: USHORT format; /* Format identifier--format = 1 */ LongOffsetArrayOf @@ -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: union { 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 { 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: FixedVersion version; /* Version of the GDEF table--currently * 0x00010002 */ diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 564816048..c245e0f4c 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -1501,7 +1501,7 @@ struct GPOS : GSUBGPOS hb_ot_layout_feature_mask_t mask) const { 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; OffsetTo &list = CAST(OffsetTo, lookupList, 0); return SANITIZE_THIS (list); diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index a8977ac57..535d63696 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -838,7 +838,7 @@ struct GSUB : GSUBGPOS { 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; OffsetTo &list = CAST(OffsetTo, lookupList, 0); return SANITIZE_THIS (list); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 4a1ab24ce..06826912a 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -848,7 +848,7 @@ struct GSUBGPOS 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) */ - inline bool sanitize (SANITIZE_ARG_DEF) { + bool sanitize (SANITIZE_ARG_DEF) { if (!SANITIZE (version)) return false; if (version.major != 1) return true; return SANITIZE_THIS3 (scriptList, featureList, lookupList);