Commit 13c4a4f171877c751ff621af2860abb5b3f00de7

Werner Lemberg 2003-04-23T18:21:48

* src/sfnt/ttcmap0.c (tt_cmap4_validate): Provide a weak variant of the glyph ID bounding check if FT_VALIDATE_TIGHT is not active. Without this change, many CJK fonts from Dynalab are rejected.

diff --git a/ChangeLog b/ChangeLog
index 387879e..dd78eb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-04-23  Akito Hirai  <akito@kde.gr.jp>
+
+	* src/sfnt/ttcmap0.c (tt_cmap4_validate): Provide a weak variant
+	of the glyph ID bounding check if FT_VALIDATE_TIGHT is not active.
+	Without this change, many CJK fonts from Dynalab are rejected.
+
 2003-04-23  Joe Marcus Clarke  <marcus@FreeBSD.org>
 
 	* src/base/ftbdf.c (FT_Get_BDF_Property): Check for valid
diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c
index 4053345..613a9f8 100644
--- a/src/sfnt/ttcmap0.c
+++ b/src/sfnt/ttcmap0.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType new character mapping table (cmap) support (body).          */
 /*                                                                         */
-/*  Copyright 2002 by                                                      */
+/*  Copyright 2002, 2003 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -701,9 +701,18 @@
           p += offset;  /* start of glyph id array */
 
           /* check that we point within the glyph ids table only */
-          if ( p < glyph_ids                                ||
-               p + ( end - start + 1 ) * 2 > table + length )
-            FT_INVALID_DATA;
+          if ( valid->level >= FT_VALIDATE_TIGHT )
+          {
+            if ( p < glyph_ids                                ||
+                 p + ( end - start + 1 ) * 2 > table + length )
+              FT_INVALID_DATA;
+          }
+          else
+          {
+            if ( p < glyph_ids                              ||
+                 p + ( end - start + 1 ) * 2 > valid->limit )
+              FT_INVALID_DATA;
+          }
 
           /* check glyph indices within the segment range */
           if ( valid->level >= FT_VALIDATE_TIGHT )