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

ASF subversion and git services commented on PDFBOX-5972:
---------------------------------------------------------

Commit 1924271 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1924271 ]

PDFBOX-5972: avoid infinite loop, as suggested by Michael Flester

> Infinite loop in fontbox o.a.f.cmap.CMapParser#readNumber
> ---------------------------------------------------------
>
>                 Key: PDFBOX-5972
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5972
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 3.0.3 PDFBox, 3.0.4 PDFBox
>            Reporter: Michael Flester
>            Priority: Major
>         Attachments: sample-decoded.pdf
>
>
> The sample document attached goes into an infinite loop in 
> o.a.f.CMapParser.readNumber.
> The attached document was created from proprietary content by using 
> o.a.p.tools.PDFSplit and o.a.p.tools.WriteDecodedDoc, so that we could remove 
> the proprietary content more easily.
>  
> The very short stream at line 225/226 happens to end with '6', and this makes 
> the current readNumber routine rewind the EOF, and leaves it unable to 
> progress.
>  
> Here is a patch that seems to fix this issue by not rewinding EOF. All 
> existing unit tests still pass with this patch (diff -w), and the sample 
> document exhibits normal behavior.
> {noformat}
> --- a/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
> +++ b/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
> @@ -652,7 +652,10 @@ public class CMapParser
>              buffer.append((char) nextByte);
>              nextByte = randomAcccessRead.read();
>          }
> +        if (nextByte != -1)
> +        {
>              randomAcccessRead.rewind(1);
> +        }
>          String value = buffer.toString();
>          try
>          { {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to