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

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

    [ https://issues.apache.org/jira/browse/PDFBOX-2008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13957972#comment-13957972 ] 

Tilman Hausherr commented on PDFBOX-2008:
-----------------------------------------

Although I wonder why you would have a generation number of 65535 (isn't this incremented by one for a new version?), the PDF spec is clear about this: "The maximum generation number is 65,535".

> 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.
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> 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)