pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1844567 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Date Mon, 22 Oct 2018 16:28:06 GMT
Author: lehmi
Date: Mon Oct 22 16:28:06 2018
New Revision: 1844567

URL: http://svn.apache.org/viewvc?rev=1844567&view=rev
Log:
PDFBOX-4354: avoid NumberFormatException

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=1844567&r1=1844566&r2=1844567&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
Oct 22 16:28:06 2018
@@ -323,8 +323,7 @@ public class COSParser extends BaseParse
             {
                 // xref table and trailer
                 // use existing parser to parse xref table
-                parseXrefTable(prev);
-                if (!parseTrailer())
+                if (!parseXrefTable(prev) || !parseTrailer())
                 {
                     throw new IOException("Expected trailer object at offset "
                             + source.getPosition());
@@ -2695,12 +2694,31 @@ public class COSParser extends BaseParse
             if (splitString.length != 2)
             {
                 LOG.warn("Unexpected XRefTable Entry: " + currentLine);
-                break;
+                return false;
             }
             // first obj id
-            long currObjID = Long.parseLong(splitString[0]);
+            long currObjID = 0;
+            try
+            {
+                currObjID = Long.parseLong(splitString[0]);
+            }
+            catch (NumberFormatException exception)
+            {
+                LOG.warn("XRefTable: invalid ID for the first object: " + currentLine);
+                return false;
+            }
+
             // the number of objects in the xref table
-            int count = Integer.parseInt(splitString[1]);
+            int count = 0;
+            try
+            {
+                count = Integer.parseInt(splitString[1]);
+            }
+            catch (NumberFormatException exception)
+            {
+                LOG.warn("XRefTable: invalid number of objects: " + currentLine);
+                return false;
+            }
             
             skipSpaces();
             for(int i = 0; i < count; i++)



Mime
View raw message