From 5b591e49cf3c87fddeb44acc8a6b6d3a4fbda31a Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 1 Jun 2007 22:16:43 +0000 Subject: [PATCH] * include/freetype/fterrdef.h (FT_Err_Corrupted_Font_Header, FT_Err_Corrupted_Font_Glyphs): New error codes for BDF files. * src/bdf/bdflib.c (bdf_load_font): Use them. * src/bdf/bdflib.c (_bdf_parse_start): Check `FONT' better. --- ChangeLog | 9 +++++++++ include/freetype/fterrdef.h | 6 +++++- src/bdf/bdflib.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 485232180..d9bb6bc0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-02 Werner Lemberg + + * include/freetype/fterrdef.h (FT_Err_Corrupted_Font_Header, + FT_Err_Corrupted_Font_Glyphs): New error codes for BDF files. + + * src/bdf/bdflib.c (bdf_load_font): Use them. + + * src/bdf/bdflib.c (_bdf_parse_start): Check `FONT' better. + 2007-06-01 Werner Lemberg * src/base/ftobjs.c (FT_Request_Metrics), src/cache/ftccmap.c diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h index ab8c3f7d9..d7ad256bd 100644 --- a/include/freetype/fterrdef.h +++ b/include/freetype/fterrdef.h @@ -4,7 +4,7 @@ /* */ /* FreeType error codes (specification). */ /* */ -/* Copyright 2002, 2004, 2006 by */ +/* Copyright 2002, 2004, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -230,6 +230,10 @@ "`BBX' field missing" ) FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \ "`BBX' too big" ) + FT_ERRORDEF_( Corrupted_Font_Header, 0xB8, \ + "Font header corrupted or missing fields" ) + FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xB9, \ + "Font glyphs corrupted or missing fields" ) /* END */ diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 8dade71ba..512cd62c3 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -2123,6 +2123,13 @@ _bdf_list_shift( &p->list, 1 ); s = _bdf_list_join( &p->list, ' ', &slen ); + + if ( !s ) + { + error = BDF_Err_Invalid_File_Format; + goto Exit; + } + if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) ) goto Exit; FT_MEM_COPY( p->font->name, s, slen + 1 ); @@ -2307,11 +2314,19 @@ { /* The ENDFONT field was never reached or did not exist. */ if ( !( p->flags & _BDF_GLYPHS ) ) + { /* Error happened while parsing header. */ FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno )); + error = BDF_Err_Corrupted_Font_Header; + goto Exit; + } else + { /* Error happened when parsing glyphs. */ FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno )); + error = BDF_Err_Corrupted_Font_Glyphs; + goto Exit; + } } }