diff --git a/ChangeLog b/ChangeLog index 0971afcb0..23747712c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-10-17 Werner Lemberg + + [bdf] Use stream size to adjust number of glyphs. + + * src/bdf/bdflib.c (ACMSG17): New message macro. + (_bdf_parse_t): Add member `size'. + (bdf_load_font): Set `size'. + (_bdf_parse_glyphs): Adjust `cnt' if necessary. + 2015-10-17 Werner Lemberg * src/cid/cidload.c (cid_parse_dict): Check `[FG]DBytes' size. diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 5b1beef8a..4f3b4fd6a 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -201,6 +201,7 @@ #define ACMSG14 "Glyph %ld extra columns removed.\n" #define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n" #define ACMSG16 "Glyph %ld missing columns padded with zero bits.\n" +#define ACMSG17 "Adjusting number of glyphs to %ld.\n" /* Error messages. */ #define ERRMSG1 "[line %ld] Missing `%s' line.\n" @@ -432,6 +433,7 @@ _bdf_list_t list; FT_Memory memory; + unsigned long size; /* the stream size */ } _bdf_parse_t; @@ -1579,6 +1581,13 @@ goto Exit; p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 ); + /* We need at least 20 bytes per glyph. */ + if ( p->cnt > p->size / 20 ) + { + p->cnt = p->size / 20; + FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG17, p->cnt )); + } + /* Make sure the number of glyphs is non-zero. */ if ( p->cnt == 0 ) font->glyphs_size = 64; @@ -2447,6 +2456,7 @@ memory = NULL; p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts ); p->minlb = 32767; + p->size = stream->size; p->memory = extmemory; /* only during font creation */ _bdf_list_init( &p->list, extmemory );