* 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/ChangeLog b/ChangeLog
index 4852321..d9bb6bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-02 Werner Lemberg <wl@gnu.org>
+
+ * 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 <wl@gnu.org>
* src/base/ftobjs.c (FT_Request_Metrics), src/cache/ftccmap.c
diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h
index ab8c3f7..d7ad256 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 8dade71..512cd62 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;
+ }
}
}