Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3839

AIOOB in PDResources.getFont()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6
    • 2.0.7, 3.0.0 PDFBox
    • FontBox, Parsing
    • None

    Description

      As reported by Lauri Laanti in the users mailing list:

      java.lang.ArrayIndexOutOfBoundsException: 4
      at org.apache.fontbox.ttf.PostScriptTable.getName(PostScriptTable.java:318)
      at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.readEncodingFromFont(PDTrueTypeFont.java:260)
      at org.apache.pdfbox.pdmodel.font.PDSimpleFont.readEncoding(PDSimpleFont.java:134)
      at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.<init>(PDTrueTypeFont.java:209)
      at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:75)
      at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:143)
      
      
      Investigating the function in question:
      
      public String getName(int gid)
      313            {
      314                if (gid < 0 || glyphNames == null || gid > glyphNames.length)
      315                {
      316                    return null;
      317                }
      318                return glyphNames[gid];
      319            }
      
      I think that the check on line 314 should be :
      
      gid < 0 || glyphNames == null || gid >= glyphNames.length
      
      Otherwise, when gid == glyphNames.length there will be AIOOB.
      

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            tilman Tilman Hausherr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: