pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1548387 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
Date Fri, 06 Dec 2013 07:15:36 GMT
Author: msahyoun
Date: Fri Dec  6 07:15:36 2013
New Revision: 1548387

URL: http://svn.apache.org/r1548387
Log:
Fix for infinite loop in parseCOSHexString [PDFBOX-1796] 

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1548387&r1=1548386&r2=1548387&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Fri Dec
 6 07:15:36 2013
@@ -1008,7 +1008,15 @@ public abstract class BaseParser
                 do 
                 {
                     c = pdfSource.read();
-                } while ( c != '>' );
+                } while ( c != '>' && c < 0 );
+                
+                // might have reached EOF while looking for the closing bracket
+                // this can happen for malformed PDFs only. Make sure that there is
+                // no endless loop.
+                if ( c < 0 ) 
+                {
+                    throw new IOException( "Missing closing bracket for hex string. Reached
EOS." );
+                }
                 
                 // exit loop
                 break;



Mime
View raw message