You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Christian S. (JIRA)" <ji...@apache.org> on 2014/04/02 18:09:14 UTC

[jira] [Created] (PDFBOX-2008) Off-by-one error in BaseParser.readGenerationNumber()

Christian S. created PDFBOX-2008:
------------------------------------

             Summary: Off-by-one error in BaseParser.readGenerationNumber()
                 Key: PDFBOX-2008
                 URL: https://issues.apache.org/jira/browse/PDFBOX-2008
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 1.8.4
            Reporter: Christian S.


wrong:
         if(retval < 0 || retval >= GENERATION_NUMBER_THRESHOLD) ...

correct:
        if(retval < 0 || retval > GENERATION_NUMBER_THRESHOLD) ...

The method comment describes the correct behavior:
"if the integer value has more than the maximum object revision (i.e. : bigger than {@link #GENERATION_NUMBER_THRESHOLD}) ..."

This is not a theoretical bug. I've scanned our database of quite a few pdf documents and found one which were not readable / mergeable by PdfBox:

java.io.IOException: Generation Number '65535' has more than 5 digits
	at org.apache.pdfbox.pdfparser.BaseParser.readGenerationNumber(BaseParser.java:1629)
	at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:574)
	at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:194)
	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1219)
	at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1186)
	at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:191)
 



--
This message was sent by Atlassian JIRA
(v6.2#6252)