Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6349101

offset bug in sun.font.TrueTypeFont.lookupName() causing JCK 15a test failure for certain TTF files

XMLWordPrintable

    • 2d
    • b63
    • generic
    • generic

      On Red Flag DC Server 5.0 Linux, we hit a bug in the Sun JDK 5.0
      Update 4 causing failure of the JCK 15a test:
      api/java_awt/GraphicsEnvironment/index.html#GetAFFamilyNames.
       
      The problem was tracked down to be a bug in the method
      sun.font.TrueTypeFont.lookupName() that only is triggered for certain
      TrueType font files, in this case a font file from the RPM package
      ttfonts-zh_TW-5.0-2AX.noarch.rpm.

      The actual bug is that the offset in the 'name' table is an unsigned
      16-bit type that is stored in a 'short' which is a signed 16-bit type.
      In this case the offset of the searched for table entry is larger than
      32767 which causes a negative value to be stored in the 'short' and sent
      to ShortBuffer.position() that throws an IllegalArgumentException.

      The following short program triggers the bug on all platforms, both
      Windows and Linux:

      -----<------
      import java.awt.Font;
      import java.io.File;
      import java.util.Locale;
      import sun.font.Font2D;
      import sun.font.FontManager;
      import sun.font.TrueTypeFont;

      public class BugRepro {
          public static void main(String[] args) throws Exception {
      File fontFile = new File(args[0]);
      TrueTypeFont ttf = (TrueTypeFont)
      FontManager.createFont2D(fontFile,
      Font.TRUETYPE_FONT, false);
      ttf.getFamilyName(Locale.CHINA);
          }
      }
      -----<-----
      using any of the .ttf-files in ttfonts-zh_TW-5.0-2AX.noarch.rpm as
      input, e.g.
      /usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf.

            igor Igor Nekrestyanov (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: