Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-2008

Off-by-one error in BaseParser.readGenerationNumber()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.4, 1.8.5, 2.0.0
    • Fix Version/s: 1.8.5, 2.0.0
    • Component/s: None
    • Labels:
      None

      Description

      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)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cs1 Christian S.
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.25h
                0.25h
                Remaining:
                Remaining Estimate - 0.25h
                0.25h
                Logged:
                Time Spent - Not Specified
                Not Specified