You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Michael Flester (Jira)" <ji...@apache.org> on 2025/03/10 12:55:00 UTC

[jira] [Created] (PDFBOX-5972) Infinite loop in fontbox o.a.f.cmap.CMapParser#readNumber

Michael Flester created PDFBOX-5972:
---------------------------------------

             Summary: 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.4 PDFBox, 3.0.3 PDFBox
            Reporter: Michael Flester
         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-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org