[
https://issues.apache.org/jira/browse/PDFBOX-6320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Mirchev updated PDFBOX-6320:
-----------------------------------
Attachment: type4-underflow.pdf
> Malformed type 4 functions throw EmptyStackException / ClassCastException out
> of rendering
> ------------------------------------------------------------------------------------------
>
> Key: PDFBOX-6320
> URL: https://issues.apache.org/jira/browse/PDFBOX-6320
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 3.0.8 PDFBox, 4.0.0
> Reporter: Martin Mirchev
> Priority: Major
> Attachments: type4-bitshift.pdf, type4-underflow.pdf
>
>
> Errors while evaluating a PostScript calculator (type 4) function are not
> caught, so they escape {{PDFRenderer.renderImage()}} as unchecked exceptions:
> * Attached {{type4-underflow.pdf}}: a Separation tint transform \{ pop pop
> add \} throws {{java.util.EmptyStackException}} from
> {{StackOperators$Pop.execute(StackOperators.java:107)}}.
> * Attached {{type4-bitshift.pdf}}: \{ 1.5 1 bitshift dup dup \} throws
> {{ClassCastException: Float cannot be cast to Integer}} from
> {{BitwiseOperators$Bitshift.execute(BitwiseOperators.java:94)}}.
> {code}
> at
> org.apache.pdfbox.pdmodel.common.function.type4.InstructionSequence.execute(InstructionSequence.java:91)
> at
> org.apache.pdfbox.pdmodel.common.function.PDFunctionType4.eval(PDFunctionType4.java:74)
> at
> org.apache.pdfbox.pdmodel.graphics.color.PDSeparation.toRGB(PDSeparation.java:137)
> at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:370)
> at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:893)
> {code}
> The same file with \{ dup dup \} renders (trunk bd0c9c0, 3/3 runs). Wrapping
> these in an {{IOException}} in {{PDFunctionType4.eval()}} (or checking the
> stack depth and operand types) would let callers handle them like other
> malformed content.
> 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]