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

Errors in Stream Object Parsing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.8.0-incubator, 1.0.0
    • 1.1.0
    • Parsing
    • None

    Description

      The readUntilEndStream method in org.apache.pdfbox.pdfparser.BaseParser doesn't work properly. The read(byte[]) method doesn't guarantee that it will fill the buffer, and as long as the buffer hasn't been filled the value of nextIdx will be wrong. For example, say the call to read returns 5 bytes in the buffer. nextIdx will have value 5, i.e. points to a yet uninitialized byte that will be written to the output stream. Same at the next loop iteration, and in the end the stream will start with 4 null bytes that don't belong to the original one.

      Also, if the stream is terminated by endobj instead of endstream, the possible bytes that are at the beginning of the buffer and precede endobj won't be written out. The for loop will stop at the end of the buffer instead of looping back to the beginning of it if necessary (say, if endobj happens to occupy slots 3 to 8 of the buffer).

      Attachments

        1. fixStreamParsing.diff
          3 kB
          Vincent Hennebert

        Activity

          People

            Unassigned Unassigned
            vhennebert Vincent Hennebert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: