[
https://issues.apache.org/jira/browse/PDFBOX-6319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18148539#comment-18148539
]
ASF subversion and git services commented on PDFBOX-6319:
---------------------------------------------------------
Commit 1940612 from Tilman Hausherr in branch 'pdfbox/branches/3.0'
[ https://svn.apache.org/r1940612 ]
PDFBOX-6319: avoid ClassCastException
> CIDFont /W range up to Integer.MAX_VALUE causes OutOfMemoryError; /W2
> non-number entry causes ClassCastException
> ----------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-6319
> URL: https://issues.apache.org/jira/browse/PDFBOX-6319
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 3.0.8 PDFBox, 4.0.0
> Reporter: Martin Mirchev
> Priority: Major
> Attachments: w-range-intmax.pdf, w2-name.pdf
>
>
> Two problems in {{PDCIDFont}} when reading crafted width arrays.
> 1. {{readWidths()}} expands a {{c_first c_last w}} range into one map entry
> per CID:
> {code:java}
> for (int i = startRange; i <= endRange; i++)
> {
> widths.put(i, width);
> }
> {code}
> Attached {{w-range-intmax.pdf}} has {{/W [0 2147483647 500]}}: rendering the
> page fails with {{OutOfMemoryError}} in
> {{PDCIDFont.readWidths(PDCIDFont.java:167)}} while the font is created (from
> {{PDResources.getFont}}, -Xmx1g). With {{endRange == Integer.MAX_VALUE}} the
> loop would also never end, because {{i}} wraps. PDFBOX-6175 stopped expanding
> {{/W2}} ranges per CID ({{VerticalDisplacementRange}}); {{/W}} ranges could
> be kept as ranges in the same way.
> 2. {{readVerticalDisplacements()}} casts {{/W2}} entries to {{COSNumber}}
> without checks, while {{readWidths()}} logs and skips non-number entries.
> Attached {{w2-name.pdf}} has {{/W2 [/X [1000 0 0]]}} and rendering fails with
> {{ClassCastException: COSName cannot be cast to COSNumber}} at
> {{PDCIDFont.readVerticalDisplacements(PDCIDFont.java:195)}}. PDFBOX-3963
> fixed an earlier case in the same method.
> Both on trunk bd0c9c0, 3/3 runs; {{/W [0 100 500]}} and a well-formed {{/W2}}
> load without errors.
> This issue was found by an LLM-assisted tool and verified manually.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]