You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Dennis Noordsij (Jira)" <ji...@apache.org> on 2020/09/24 18:37:00 UTC

[jira] [Comment Edited] (PDFBOX-4965) Stack overflow in PDFCloneUtility

    [ https://issues.apache.org/jira/browse/PDFBOX-4965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17201584#comment-17201584 ] 

Dennis Noordsij edited comment on PDFBOX-4965 at 9/24/20, 6:36 PM:
-------------------------------------------------------------------

I've found the culprit, there is a chain of dictionary entries like:

{{%% Original object ID: 615 0 }}
{{627 0 obj }}
{{<< }}
{{/Dest [ }}
{{  15 0 R }}
{{  /XYZ }}
{{  428 }}
{{  392 }}
{{  0 }}
{{  ] }}
{{ /Next 625 0 R }}
{{ /Parent 5 0 R }}
{{ /Prev 629 0 R }}
{{ /Title (position_1516796_2160) }}
{{>> }}
{{endobj }}

that is over 5000 entries in length.

The document is just a couple of pages of text, but it was created by Microsoft Word .....

 

With a larger stack size it works. However it is still possible to craft a PDF file that will cause a stackoverflow when used in the merger utility. Perhaps the cloneForNewDocument can be implemented without recursion.

 


was (Author: dennisn):
java.lang.StackOverflowError
 at java.util.HashMap.putVal(HashMap.java:629)
 at java.util.HashMap.put(HashMap.java:612)
 at java.util.HashSet.add(HashSet.java:220)
 at org.apache.pdfbox.util.SmallMap.entrySet(SmallMap.java:383)
 at org.apache.pdfbox.cos.COSDictionary.entrySet(COSDictionary.java:1398)
 at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:142)
 at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:109)

> Stack overflow in PDFCloneUtility
> ---------------------------------
>
>                 Key: PDFBOX-4965
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4965
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.0.21
>         Environment: FreeBSD
>            Reporter: Dennis Noordsij
>            Priority: Major
>
> My production system crashed with the following trace:
> java.lang.StackOverflowError
>  at java.util.HashMap.hash(HashMap.java:339)
>  at java.util.HashMap.get(HashMap.java:557)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:81)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:146)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:109)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:146)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:109)
>  at org.apache.pdfbox.multipdf.PDFCloneUtility.cloneForNewDocument(PDFCloneUtility.java:146)
> (repeated)
>  
> We do a lot with PDF files and I don't have the actual PDF or action which caused this at the moment, but perhaps this already rings a bell with someone of what kind of bug this could be or wether I am doing something strange?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org