* src/base/ftmac.c: Fix a bug of PostScript font name synthesis in parse_fond().
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
diff --git a/ChangeLog b/ChangeLog
index 48d9358..3e10c99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2008-02-21 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+ * src/base/ftmac.c: Fix a bug of PostScript font name synthesis
+ in parse_fond(). For any face of a specified FOND, always the
+ name for the first face was used. Except of a FOND that refers
+ multiple Type1 font files, wrong synthesized font names are not
+ used at all, so this is invisible bug. A few limit checks are
+ added to parse_fond().
+
+ * builds/mac/ftmac.c: Ditto.
+
+2008-02-21 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
* builds/unix/configure.raw: Split compiler option to link Carbon
frameworks to one option for CoreServices framework and another
option for ApplicationServices framework. The split options can be
diff --git a/builds/mac/ftmac.c b/builds/mac/ftmac.c
index b0b79ea..e5e2964 100644
--- a/builds/mac/ftmac.c
+++ b/builds/mac/ftmac.c
@@ -727,6 +727,10 @@ typedef short ResourceIndex;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
base_assoc = assoc;
+ /* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
+ if ( 47 < face_index )
+ return;
+
/* Let's do a little range checking before we get too excited here */
if ( face_index < count_faces_sfnt( fond_data ) )
{
@@ -778,9 +782,10 @@ typedef short ResourceIndex;
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
ps_name[ps_name_len] = 0;
}
- if ( style->indexes[0] > 1 )
+ if ( style->indexes[face_index] > 1 &&
+ style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
{
- unsigned char* suffixes = names[style->indexes[0] - 1];
+ unsigned char* suffixes = names[style->indexes[face_index] - 1];
for ( i = 1; i <= suffixes[0]; i++ )
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 8aa08c3..0b11c50 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -395,6 +395,10 @@ typedef short ResourceIndex;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
base_assoc = assoc;
+ /* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
+ if ( 47 < face_index )
+ return;
+
/* Let's do a little range checking before we get too excited here */
if ( face_index < count_faces_sfnt( fond_data ) )
{
@@ -446,9 +450,10 @@ typedef short ResourceIndex;
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
ps_name[ps_name_len] = 0;
}
- if ( style->indexes[0] > 1 )
+ if ( style->indexes[face_index] > 1 &&
+ style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
{
- unsigned char* suffixes = names[style->indexes[0] - 1];
+ unsigned char* suffixes = names[style->indexes[face_index] - 1];
for ( i = 1; i <= suffixes[0]; i++ )