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