From 009ce1aba8f9aed1703cd44538230263e01262bc Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 28 Aug 2004 07:59:53 +0000 Subject: [PATCH] * src/otlayout/otlayout.h: Add copyright. (OTL_INVALID_OFFSET): Removed. * src/otlayout/otlgdef.h: Include otlayout.h. Comment out inclusion of otltable.h. * src/otlayout/otlgpos.c (otl_gpos_lookup4_validate): Fix call to otl_base_array_validate. (otl_liga_mark2_validate): Fix `for' loop. * src/otlayout/otlgsub.c (otl_ligature_validate): Check `glyph_id', not components array. * src/otlcommn.c (otl_lookup_get_count, otl_feature_get_count): Comment out. (otl_lookup_list_get_count, otl_feature_list_get_count): Activate. (otl_feature_list_validate, otl_gsubgpos_get_lookup_count): s/otl_lookup_get_count/otl_lookup_list_get_count/. (otl_script_list_validate): s/otl_feature_get_count/otl_feature_list_get_count/. (otl_script_validate): Call otl_lang_validate for default language. * src/otlayout/otlcommn.h: Updated. --- ChangeLog | 26 ++++++++++++++++++++++++++ src/otlayout/otlayout.h | 22 +++++++++++++++++++++- src/otlayout/otlcommn.c | 19 ++++++++----------- src/otlayout/otlcommn.h | 8 ++++---- src/otlayout/otlgdef.h | 4 ++++ src/otlayout/otlgpos.c | 4 ++-- src/otlayout/otlgsub.c | 9 ++++----- 7 files changed, 69 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50e8012b7..1ccb500bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2004-08-27 Werner Lemberg + + * src/otlayout/otlayout.h: Add copyright. + (OTL_INVALID_OFFSET): Removed. + + * src/otlayout/otlgdef.h: Include otlayout.h. + Comment out inclusion of otltable.h. + + * src/otlayout/otlgpos.c (otl_gpos_lookup4_validate): Fix call + to otl_base_array_validate. + (otl_liga_mark2_validate): Fix `for' loop. + + * src/otlayout/otlgsub.c (otl_ligature_validate): Check `glyph_id', + not components array. + + * src/otlcommn.c (otl_lookup_get_count, otl_feature_get_count): + Comment out. + (otl_lookup_list_get_count, otl_feature_list_get_count): Activate. + (otl_feature_list_validate, otl_gsubgpos_get_lookup_count): + s/otl_lookup_get_count/otl_lookup_list_get_count/. + (otl_script_list_validate): + s/otl_feature_get_count/otl_feature_list_get_count/. + (otl_script_validate): Call otl_lang_validate for default language. + + * src/otlayout/otlcommn.h: Updated. + 2004-08-16 Werner Lemberg * src/otlayout/otlgpos.c (otl_gpos_lookup1_validate, diff --git a/src/otlayout/otlayout.h b/src/otlayout/otlayout.h index 21988f390..c177cc2aa 100644 --- a/src/otlayout/otlayout.h +++ b/src/otlayout/otlayout.h @@ -1,3 +1,21 @@ +/***************************************************************************/ +/* */ +/* otlayout.h */ +/* */ +/* OpenType layout support (specification only). */ +/* */ +/* Copyright 2002, 2004 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + #ifndef __OT_LAYOUT_H__ #define __OT_LAYOUT_H__ @@ -200,7 +218,6 @@ OTL_BEGIN_HEADER #define OTL_INVALID(e) otl_validator_error( valid, e ) #define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidSize ) -#define OTL_INVALID_OFFSET OTL_INVALID( OTL_Err_InvalidOffset ) #define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidData ) #define OTL_INVALID_FORMAT OTL_INVALID( OTL_Err_InvalidFormat ) @@ -214,3 +231,6 @@ OTL_BEGIN_HEADER OTL_END_HEADER #endif /* __OT_LAYOUT_H__ */ + + +/* END */ diff --git a/src/otlayout/otlcommn.c b/src/otlayout/otlcommn.c index 802266e17..d84116770 100644 --- a/src/otlayout/otlcommn.c +++ b/src/otlayout/otlcommn.c @@ -512,6 +512,7 @@ } +#if 0 OTL_LOCALDEF( OTL_UInt ) otl_lookup_get_count( OTL_Bytes table ) { @@ -520,6 +521,7 @@ return OTL_PEEK_USHORT( p ); } +#endif #if 0 @@ -575,7 +577,6 @@ } -#if 0 OTL_LOCALDEF( OTL_UInt ) otl_lookup_list_get_count( OTL_Bytes table ) { @@ -584,7 +585,6 @@ return OTL_PEEK_USHORT( p ); } -#endif #if 0 @@ -671,6 +671,7 @@ } +#if 0 OTL_LOCALDEF( OTL_UInt ) otl_feature_get_count( OTL_Bytes table ) { @@ -679,6 +680,7 @@ return OTL_PEEK_USHORT( p ); } +#endif #if 0 @@ -730,7 +732,7 @@ num_features = OTL_NEXT_USHORT( p ); OTL_CHECK( 2 * num_features ); - lookup_count = otl_lookup_get_count( lookups ); + lookup_count = otl_lookup_list_get_count( lookups ); /* scan feature records */ for ( ; num_features > 0; num_features-- ) @@ -743,7 +745,6 @@ } -#if 0 OTL_LOCALDEF( OTL_UInt ) otl_feature_list_get_count( OTL_Bytes table ) { @@ -752,7 +753,6 @@ return OTL_PEEK_USHORT( p ); } -#endif #if 0 @@ -906,10 +906,7 @@ num_langs = OTL_NEXT_USHORT( p ); if ( default_lang != 0 ) - { - if ( table + default_lang >= valid->limit ) - OTL_INVALID_OFFSET; - } + otl_lang_validate( table + default_lang, feature_count, valid ); OTL_CHECK( num_langs * 6 ); @@ -936,7 +933,7 @@ num_scripts = OTL_NEXT_USHORT( p ); OTL_CHECK( num_scripts * 6 ); - feature_count = otl_feature_get_count( features ); + feature_count = otl_feature_list_get_count( features ); /* scan script records */ for ( ; num_scripts > 0; num_scripts-- ) @@ -963,7 +960,7 @@ OTL_Bytes p = table + 8; - return otl_lookup_get_count( table + OTL_PEEK_USHORT( p ) ); + return otl_lookup_list_get_count( table + OTL_PEEK_USHORT( p ) ); } diff --git a/src/otlayout/otlcommn.h b/src/otlayout/otlcommn.h index de8e7477d..000d5abfe 100644 --- a/src/otlayout/otlcommn.h +++ b/src/otlayout/otlcommn.h @@ -128,9 +128,11 @@ OTL_BEGIN_HEADER OTL_UInt glyph_count, OTL_Validator valid ); +#if 0 /* return number of sub-tables in a lookup */ OTL_LOCAL( OTL_UInt ) otl_lookup_get_count( OTL_Bytes table ); +#endif #if 0 /* return lookup sub-table */ @@ -156,11 +158,9 @@ OTL_BEGIN_HEADER OTL_UInt glyph_count, OTL_Validator valid ); -#if 0 /* return number of lookups in list */ OTL_LOCAL( OTL_UInt ) otl_lookup_list_get_count( OTL_Bytes table ); -#endif #if 0 /* return a given lookup from a list */ @@ -200,9 +200,11 @@ OTL_BEGIN_HEADER OTL_UInt lookup_count, OTL_Validator valid ); +#if 0 /* return feature's lookup count */ OTL_LOCAL( OTL_UInt ) otl_feature_get_count( OTL_Bytes table ); +#endif #if 0 /* get several lookups indices from a feature. returns the number of */ @@ -230,11 +232,9 @@ OTL_BEGIN_HEADER OTL_Bytes lookups, OTL_Validator valid ); -#if 0 /* return number of features in list */ OTL_LOCAL( OTL_UInt ) otl_feature_list_get_count( OTL_Bytes table ); -#endif #if 0 /* return a given feature from a list */ diff --git a/src/otlayout/otlgdef.h b/src/otlayout/otlgdef.h index 359cdf91b..dc7d41bb2 100644 --- a/src/otlayout/otlgdef.h +++ b/src/otlayout/otlgdef.h @@ -19,7 +19,11 @@ #ifndef __OTLGDEF_H__ #define __OTLGDEF_H__ +#include "otlayout.h" + +#if 0 #include "otltable.h" +#endif OTL_BEGIN_HEADER diff --git a/src/otlayout/otlgpos.c b/src/otlayout/otlgpos.c index f3de23788..6c264330d 100644 --- a/src/otlayout/otlgpos.c +++ b/src/otlayout/otlgpos.c @@ -477,7 +477,7 @@ otl_coverage_validate( table + base_coverage, valid ); otl_mark_array_validate( table + mark_array, valid ); - otl_base_array_validate( table, num_classes, valid ); + otl_base_array_validate( table + base_array, num_classes, valid ); } break; @@ -514,7 +514,7 @@ /* scan component records */ for ( ; num_components > 0; num_components-- ) /* scan ligature anchor records */ - for ( count = class_count; class_count > 0; class_count-- ) + for ( count = class_count; count > 0; count-- ) { OTL_UInt offset = OTL_NEXT_USHORT( p ); diff --git a/src/otlayout/otlgsub.c b/src/otlayout/otlgsub.c index 5a6b820b9..ca41d6d57 100644 --- a/src/otlayout/otlgsub.c +++ b/src/otlayout/otlgsub.c @@ -484,7 +484,10 @@ OTL_CHECK( 4 ); - glyph_id = OTL_NEXT_USHORT( p ); + glyph_id = OTL_NEXT_USHORT( p ); + if ( glyph_id >= glyph_count ) + OTL_INVALID_DATA; + num_components = OTL_NEXT_USHORT( p ); if ( num_components == 0 ) @@ -493,10 +496,6 @@ num_components--; OTL_CHECK( num_components * 2 ); - - for ( ; num_components > 0; num_components-- ) - if ( OTL_NEXT_USHORT( p ) >= glyph_count ) - OTL_INVALID_DATA; }