Cleanup Extension sanitize()
This commit is contained in:
parent
1856184b93
commit
3b2c2df41b
|
@ -264,21 +264,8 @@ struct LookupFlag : USHORT
|
||||||
};
|
};
|
||||||
ASSERT_SIZE (LookupFlag, 2);
|
ASSERT_SIZE (LookupFlag, 2);
|
||||||
|
|
||||||
struct LookupSubTable
|
|
||||||
{
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
|
||||||
TRACE_SANITIZE ();
|
|
||||||
return SANITIZE_SELF ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
USHORT format; /* Subtable format. Different for GSUB and GPOS */
|
|
||||||
};
|
|
||||||
ASSERT_SIZE (LookupSubTable, 2);
|
|
||||||
|
|
||||||
struct Lookup
|
struct Lookup
|
||||||
{
|
{
|
||||||
inline const LookupSubTable& get_subtable (unsigned int i) const { return this+subTable[i]; }
|
|
||||||
inline unsigned int get_subtable_count (void) const { return subTable.len; }
|
inline unsigned int get_subtable_count (void) const { return subTable.len; }
|
||||||
|
|
||||||
inline unsigned int get_type (void) const { return lookupType; }
|
inline unsigned int get_type (void) const { return lookupType; }
|
||||||
|
@ -295,9 +282,8 @@ struct Lookup
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
/* We sanitize subtables shallow here since we don't have their actual
|
/* Real sanitize of the subtables is done by GSUB/GPOS/... */
|
||||||
* type. Real sanitize of the referenced data is done by GSUB/GPOS/... */
|
if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize (SANITIZE_ARG)))) return false;
|
||||||
if (!(SANITIZE_SELF () && HB_LIKELY (subTable.sanitize_shallow (SANITIZE_ARG)))) return false;
|
|
||||||
if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
|
if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet))
|
||||||
{
|
{
|
||||||
USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
|
USHORT &markFilteringSet = StructAfter<USHORT> (subTable);
|
||||||
|
@ -308,7 +294,7 @@ struct Lookup
|
||||||
|
|
||||||
USHORT lookupType; /* Different enumerations for GSUB and GPOS */
|
USHORT lookupType; /* Different enumerations for GSUB and GPOS */
|
||||||
USHORT lookupFlag; /* Lookup qualifiers */
|
USHORT lookupFlag; /* Lookup qualifiers */
|
||||||
OffsetArrayOf<LookupSubTable>
|
ArrayOf<Offset>
|
||||||
subTable; /* Array of SubTables */
|
subTable; /* Array of SubTables */
|
||||||
USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets
|
USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets
|
||||||
* structure. This field is only present if bit
|
* structure. This field is only present if bit
|
||||||
|
|
|
@ -1358,7 +1358,11 @@ struct ExtensionPos : Extension
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline const struct PosLookupSubTable& get_subtable (void) const
|
inline const struct PosLookupSubTable& get_subtable (void) const
|
||||||
{ return CONST_CAST (PosLookupSubTable, Extension::get_subtable (), 0); }
|
{
|
||||||
|
unsigned int offset = get_offset ();
|
||||||
|
if (HB_UNLIKELY (!offset)) return Null(PosLookupSubTable);
|
||||||
|
return CONST_CAST (PosLookupSubTable, *this, offset);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool apply (APPLY_ARG_DEF) const;
|
inline bool apply (APPLY_ARG_DEF) const;
|
||||||
|
|
||||||
|
@ -1519,7 +1523,7 @@ struct PosLookup : Lookup
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!Lookup::sanitize (SANITIZE_ARG)) return false;
|
if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false;
|
||||||
OffsetArrayOf<PosLookupSubTable> &list = CAST (OffsetArrayOf<PosLookupSubTable>, subTable, 0);
|
OffsetArrayOf<PosLookupSubTable> &list = CAST (OffsetArrayOf<PosLookupSubTable>, subTable, 0);
|
||||||
return SANITIZE_THIS (list);
|
return SANITIZE_THIS (list);
|
||||||
}
|
}
|
||||||
|
@ -1550,7 +1554,7 @@ struct GPOS : GSUBGPOS
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
|
if (HB_UNLIKELY (!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);
|
||||||
}
|
}
|
||||||
|
@ -1574,10 +1578,12 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
|
||||||
inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
|
inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return Extension::sanitize (SANITIZE_ARG) &&
|
if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
|
||||||
(&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
|
if (HB_UNLIKELY (get_type () == PosLookupSubTable::Extension)) return false;
|
||||||
get_type () == PosLookupSubTable::Extension ||
|
|
||||||
DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
|
unsigned int offset = get_offset ();
|
||||||
|
if (HB_UNLIKELY (!offset)) return true;
|
||||||
|
return SANITIZE (CAST (PosLookupSubTable, *this, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
||||||
|
|
|
@ -563,7 +563,11 @@ struct ExtensionSubst : Extension
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline const struct SubstLookupSubTable& get_subtable (void) const
|
inline const struct SubstLookupSubTable& get_subtable (void) const
|
||||||
{ return CONST_CAST (SubstLookupSubTable, Extension::get_subtable (), 0); }
|
{
|
||||||
|
unsigned int offset = get_offset ();
|
||||||
|
if (HB_UNLIKELY (!offset)) return Null(SubstLookupSubTable);
|
||||||
|
return CONST_CAST (SubstLookupSubTable, *this, offset);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool apply (APPLY_ARG_DEF) const;
|
inline bool apply (APPLY_ARG_DEF) const;
|
||||||
|
|
||||||
|
@ -828,7 +832,7 @@ struct SubstLookup : Lookup
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!Lookup::sanitize (SANITIZE_ARG)) return false;
|
if (HB_UNLIKELY (!Lookup::sanitize (SANITIZE_ARG))) return false;
|
||||||
OffsetArrayOf<SubstLookupSubTable> &list = CAST (OffsetArrayOf<SubstLookupSubTable>, subTable, 0);
|
OffsetArrayOf<SubstLookupSubTable> &list = CAST (OffsetArrayOf<SubstLookupSubTable>, subTable, 0);
|
||||||
return SANITIZE_THIS (list);
|
return SANITIZE_THIS (list);
|
||||||
}
|
}
|
||||||
|
@ -860,7 +864,7 @@ struct GSUB : GSUBGPOS
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false;
|
if (HB_UNLIKELY (!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);
|
||||||
}
|
}
|
||||||
|
@ -884,10 +888,12 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
|
||||||
inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
|
inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return Extension::sanitize (SANITIZE_ARG) &&
|
if (HB_UNLIKELY (!Extension::sanitize (SANITIZE_ARG))) return false;
|
||||||
(&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
|
if (HB_UNLIKELY (get_type () == SubstLookupSubTable::Extension)) return false;
|
||||||
get_type () == SubstLookupSubTable::Extension ||
|
|
||||||
DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
|
unsigned int offset = get_offset ();
|
||||||
|
if (HB_UNLIKELY (!offset)) return true;
|
||||||
|
return SANITIZE (CAST (SubstLookupSubTable, *this, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
|
||||||
|
|
|
@ -836,12 +836,7 @@ struct ExtensionFormat1
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline unsigned int get_type (void) const { return extensionLookupType; }
|
inline unsigned int get_type (void) const { return extensionLookupType; }
|
||||||
inline const LookupSubTable& get_subtable (void) const
|
inline unsigned int get_offset (void) const { return extensionOffset; }
|
||||||
{
|
|
||||||
unsigned int offset = extensionOffset;
|
|
||||||
if (HB_UNLIKELY (!offset)) return Null(LookupSubTable);
|
|
||||||
return CONST_CAST (LookupSubTable, *this, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
|
@ -867,11 +862,11 @@ struct Extension
|
||||||
default:return 0;
|
default:return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline const LookupSubTable& get_subtable (void) const
|
inline unsigned int get_offset (void) const
|
||||||
{
|
{
|
||||||
switch (u.format) {
|
switch (u.format) {
|
||||||
case 1: return u.format1->get_subtable ();
|
case 1: return u.format1->get_offset ();
|
||||||
default:return Null(LookupSubTable);
|
default:return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue