diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-07-26 18:33:18 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-07-26 18:33:18 +0000 |
commit | 255cc3689ee89c83f977b647ec65ada1be14d1f1 (patch) | |
tree | 9e0905d828740ad3dd229fd91f2ba895c47eaf5f | |
parent | 9a28b0efc070c90bf0f53eae65b580ab1cf95c97 (diff) | |
download | pango-255cc3689ee89c83f977b647ec65ada1be14d1f1.tar.gz |
Skip lookups with lookup index out of range. (Patch from Behdad Esfahbod,
2005-07-26 Owen Taylor <otaylor@redhat.com>
* pango/opentype/ftxgsub.c, pango/opentype/ftxgpos.c: Skip lookups
with lookup index out of range. (Patch from Behdad Esfahbod, #171170)
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 10 | ||||
-rw-r--r-- | pango/opentype/ftxgpos.c | 30 | ||||
-rw-r--r-- | pango/opentype/ftxgsub.c | 30 |
4 files changed, 68 insertions, 12 deletions
@@ -1,3 +1,8 @@ +2005-07-26 Owen Taylor <otaylor@redhat.com> + + * pango/opentype/ftxgsub.c, pango/opentype/ftxgpos.c: Skip lookups + with lookup index out of range. (Patch from Behdad Esfahbod, #171170) + 2005-07-26 Owen Taylor <otaylor@redhat.com> Fixes for signed/unsigned in PangoAttrIterator ((#166700, @@ -42,6 +47,11 @@ Classify unicode standard additions U+0B35 (va), U+0B71 (wa) as _ct. (Also #311575) +2005-07-26 Behdad Esfahbod <pango@behdad.org> + + * pango/opentype/ftxgsub.c, pango/opentype/ftxgpos.c: Skip lookups + with lookup index out of range. (#171170) + 2005-07-25 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (line_set_resolved_dir): Always set diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 25e8cc18..750d4b4e 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,8 @@ +2005-07-26 Owen Taylor <otaylor@redhat.com> + + * pango/opentype/ftxgsub.c, pango/opentype/ftxgpos.c: Skip lookups + with lookup index out of range. (Patch from Behdad Esfahbod, #171170) + 2005-07-26 Owen Taylor <otaylor@redhat.com> Fixes for signed/unsigned in PangoAttrIterator ((#166700, @@ -42,6 +47,11 @@ Classify unicode standard additions U+0B35 (va), U+0B71 (wa) as _ct. (Also #311575) +2005-07-26 Behdad Esfahbod <pango@behdad.org> + + * pango/opentype/ftxgsub.c, pango/opentype/ftxgpos.c: Skip lookups + with lookup index out of range. (#171170) + 2005-07-25 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (line_set_resolved_dir): Always set diff --git a/pango/opentype/ftxgpos.c b/pango/opentype/ftxgpos.c index e2a71ed4..a3d163ea 100644 --- a/pango/opentype/ftxgpos.c +++ b/pango/opentype/ftxgpos.c @@ -5872,8 +5872,8 @@ FT_UShort context_length, int nesting_level ) { - FT_Error error = TT_Err_Ok; - FT_UShort i, flags; + FT_Error error = TTO_Err_Not_Covered; + FT_UShort i, flags, lookup_count; TTO_GPOSHeader* gpos = gpi->gpos; TTO_Lookup* lo; @@ -5883,6 +5883,10 @@ if ( nesting_level > TTO_MAX_NESTING_LEVEL ) return TTO_Err_Too_Many_Nested_Contexts; + lookup_count = gpos->LookupList.LookupCount; + if (lookup_index >= lookup_count) + return error; + lo = &gpos->LookupList.Lookup[lookup_index]; flags = lo->LookupFlag; @@ -6049,8 +6053,9 @@ TTO_Feature feature; FT_UInt* properties; FT_UShort* index; + FT_UShort lookup_count; - /* Each feature can only be added once once */ + /* Each feature can only be added once */ if ( !gpos || feature_index >= gpos->FeatureList.FeatureCount || @@ -6063,9 +6068,14 @@ feature = gpos->FeatureList.FeatureRecord[feature_index].Feature; index = feature.LookupListIndex; + lookup_count = gpos->LookupList.LookupCount; for ( i = 0; i < feature.LookupListCount; i++ ) - properties[index[i]] |= property; + { + FT_UShort lookup_index = index[i]; + if (lookup_index < lookup_count) + properties[lookup_index] |= property; + } return TT_Err_Ok; } @@ -6133,7 +6143,7 @@ { FT_Error error, retError = TTO_Err_Not_Covered; GPOS_Instance gpi; - FT_UShort i, j, feature_index; + FT_UShort i, j, feature_index, lookup_count; TTO_Feature feature; if ( !face || !gpos || @@ -6146,6 +6156,8 @@ gpi.r2l = r2l; gpi.dvi = dvi; + lookup_count = gpos->LookupList.LookupCount; + for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ ) { /* index of i'th feature */ @@ -6154,7 +6166,13 @@ for ( j = 0; j < feature.LookupListCount; j++ ) { - error = Do_String_Lookup( &gpi, feature.LookupListIndex[j], buffer ); + FT_UShort lookup_index = feature.LookupListIndex[j]; + + /* Skip nonexistant lookups */ + if (lookup_index >= lookup_count) + continue; + + error = Do_String_Lookup( &gpi, lookup_index, buffer ); if ( error ) { if ( error != TTO_Err_Not_Covered ) diff --git a/pango/opentype/ftxgsub.c b/pango/opentype/ftxgsub.c index 50101c58..6f085ccf 100644 --- a/pango/opentype/ftxgsub.c +++ b/pango/opentype/ftxgsub.c @@ -3939,8 +3939,8 @@ FT_UShort context_length, int nesting_level ) { - FT_Error error = TT_Err_Ok; - FT_UShort i, flags; + FT_Error error = TTO_Err_Not_Covered; + FT_UShort i, flags, lookup_count; TTO_Lookup* lo; @@ -3949,6 +3949,10 @@ if ( nesting_level > TTO_MAX_NESTING_LEVEL ) return TTO_Err_Too_Many_Nested_Contexts; + lookup_count = gsub->LookupList.LookupCount; + if (lookup_index >= lookup_count) + return error; + lo = &gsub->LookupList.Lookup[lookup_index]; flags = lo->LookupFlag; @@ -4056,8 +4060,9 @@ TTO_Feature feature; FT_UInt* properties; FT_UShort* index; + FT_UShort lookup_count; - /* Each feature can only be added once once */ + /* Each feature can only be added once */ if ( !gsub || feature_index >= gsub->FeatureList.FeatureCount || @@ -4070,9 +4075,14 @@ feature = gsub->FeatureList.FeatureRecord[feature_index].Feature; index = feature.LookupListIndex; + lookup_count = gsub->LookupList.LookupCount; for ( i = 0; i < feature.LookupListCount; i++ ) - properties[index[i]] |= property; + { + FT_UShort lookup_index = index[i]; + if (lookup_index < lookup_count) + properties[lookup_index] |= property; + } return TT_Err_Ok; } @@ -4120,13 +4130,15 @@ OTL_Buffer buffer ) { FT_Error error, retError = TTO_Err_Not_Covered; - FT_UShort i, j, feature_index; + FT_UShort i, j, feature_index, lookup_count; TTO_Feature feature; if ( !gsub || !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length ) return TT_Err_Invalid_Argument; + lookup_count = gsub->LookupList.LookupCount; + for ( i = 0; i < gsub->FeatureList.ApplyCount; i++) { feature_index = gsub->FeatureList.ApplyOrder[i]; @@ -4134,7 +4146,13 @@ for ( j = 0; j < feature.LookupListCount; j++ ) { - error = Do_String_Lookup( gsub, feature.LookupListIndex[j], buffer ); + FT_UShort lookup_index = feature.LookupListIndex[j]; + + /* Skip nonexistant lookups */ + if (lookup_index >= lookup_count) + continue; + + error = Do_String_Lookup( gsub, lookup_index, buffer ); if ( error ) { if ( error != TTO_Err_Not_Covered ) |