pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1807247 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Date Mon, 04 Sep 2017 15:27:33 GMT
Author: tilman
Date: Mon Sep  4 15:27:33 2017
New Revision: 1807247

URL: http://svn.apache.org/viewvc?rev=1807247&view=rev
Log:
PDFBOX-3919: avoid endless loop

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1807247&r1=1807246&r2=1807247&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Mon
Sep  4 15:27:33 2017
@@ -208,10 +208,9 @@ public class COSParser extends BaseParse
         document.setStartXref(startXrefOffset);
         long prev = startXrefOffset;
         // ---- parse whole chain of xref tables/object streams using PREV reference
-        long lastPrev = -1;
-        while (prev > 0 && prev != lastPrev)
+        Set<Long> prevSet = new HashSet<Long>();
+        while (prev > 0)
         {
-            lastPrev = prev;
             // seek to xref table
             source.seek(prev);
 
@@ -301,11 +300,11 @@ public class COSParser extends BaseParse
                     }
                 }
             }
-        }
-        if (prev == lastPrev)
-        {
-            //TODO better idea needed? PDFBOX-3446
-            throw new IOException("/Prev loop at offset " + prev);
+            if (prevSet.contains(prev))
+            {
+                throw new IOException("/Prev loop at offset " + prev);
+            }
+            prevSet.add(prev);
         }
         // ---- build valid xrefs out of the xref chain
         xrefTrailerResolver.setStartxref(startXrefOffset);



Mime
View raw message