shithub: freetype+ttf2subf

Download patch

ref: 5b591e49cf3c87fddeb44acc8a6b6d3a4fbda31a
parent: b9933f4b028dc64a6f59569d7ba8b747398b7602
author: Werner Lemberg <[email protected]>
date: Fri Jun 1 18:16:43 EDT 2007

* 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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-02  Werner Lemberg  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* src/base/ftobjs.c (FT_Request_Metrics), src/cache/ftccmap.c
--- 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 */
--- 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;
+        }
       }
     }