Alex Nevidomsky created PDFBOX-2655:
---------------------------------------

             Summary: PDCIDFontType2Embedder.buildCIDSet()  ArrayOutOfBounds
                 Key: PDFBOX-2655
                 URL: https://issues.apache.org/jira/browse/PDFBOX-2655
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 2.0.0
            Reporter: Alex Nevidomsky


{code}
byte[] bytes = new byte[(Collections.max(cidToGid.keySet()) + 7) / 8];
...
bytes[cid / 8] |= mask;
{code}

Problem:
[(N+7)/8] is not enough to store N/8 when N=8k (for example, 8).
(N+8)/8 or N/8+1 seem to solve the problem, but not sure about the potential 
remote consequences.

Test case:
{code}
                PDDocument document = new PDDocument();
                PDPage page = new PDPage(PDRectangle.A4);
                document.addPage(page);
                String dir = "../../resources/";
                PDType0Font font = PDType0Font.load(document, new File(dir + 
"LiberationSans-Regular.ttf"));
                PDPageContentStream stream = new PDPageContentStream(document, 
page);
                stream.beginText();
                stream.setFont(font, 12);
                stream.setLeading(12 * 1.2);
                stream.newLineAtOffset(50, 600);
                //This particular Russian letter has been
                //a trouble maker in computer system for decades )
                stream.showText("я");

                stream.endText();
                stream.close();
                document.save("example.pdf");
                document.close();
{code}





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to