You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (Jira)" <ji...@apache.org> on 2021/05/08 10:48:00 UTC

[jira] [Commented] (PDFBOX-5190) COSParser: stack overflow when reading a corrupt pdf

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

Andreas Lehmkühler commented on PDFBOX-5190:
--------------------------------------------

The given pdf is just a middle part of a pdf. The exception occurs when rebuilding the header using the brute force parser.

Object 20 0 is a compressed object stream which was modified by adding a lot 0-bytes. That leads to an interesting stream when decompressing it using a FlateFilter. In the beginning the first part of the stream is repeated several times, which isn't a real issue at all, as those object aren't added to the corresponding COSDictionary as they are already there. But after some time the following content occurs:

{code}
/Parent 0 R/Resources 13 0 R/MediaBox[0 0 595.2756 841.8898]/TrimBox [ox [ox [ox [ox [ox [ox [ox [ox [ox
{code}

"/Parent 0 R" leads to a parser error but PDFBox is more or less able to recover from it. But after "/TrimBox" the parser tries to read a COSArray. As there are a lot of consecutive "[ox" strings PDFBox runs into a recursive loop and ended up in a stack overflow. 

> COSParser: stack overflow when reading a corrupt pdf
> ----------------------------------------------------
>
>                 Key: PDFBOX-5190
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5190
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 2.0.23, 3.0.0 PDFBox
>            Reporter: Andreas Lehmkühler
>            Assignee: Andreas Lehmkühler
>            Priority: Major
>         Attachments: crash-23adb315cc495bfd4761b16f877639d73d124d5b.pdf
>
>
> The attached file leads to a StackOverflowError while loading it.



--
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