Am 22.06.2017 um 16:02 schrieb Christopher Schultz:
Lauri,

On 6/22/17 7:13 AM, [email protected] wrote:
I received the following error (v 2.0.6)

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.

How do I submit this small fix?
Good catch.

I don't know if PDFBox has a GitHub mirror, so here's the "traditional" way:

1. Download and make sure you can build PDFBox:
https://pdfbox.apache.org/building.html

2. Write a test case that reproduces the error with the current code

3. Edit PostScriptTable.java and apply your fix.

4. Make sure your test case now passes :)

5. Run this command to generate a patch file:

$ svn diff > PostScriptTable.NPE.patch

6. File a JIRA ticket here:
https://issues.apache.org/jira/browse/PDFBOX

7. Attach your patch from step #5 to the JIRA ticket

8. Profit!

Hope that helps,
-chris


Indeed...

But I've opened https://issues.apache.org/jira/browse/PDFBOX-3839 myself for you. If possible, please upload a sample PDF file there or on a sharehoster.

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to