PDF-Hul: Bug in skipIISBytes and PdfModule.getObject #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many documents returning Invalid Page Dictionary Object seem to be the result of a bug in PdfFlateInputStream.skipIISBytes which is miscalculating the number of bytes to skip when the requested skip number is larger than the remaining buffer size.
In particular, this seems to relate to Page Trees encoded in stream objects where the root page starts beyond one buffer's worth of data.
The added InvalidPageDictionary.pdf file exemplifies this problem.
Note solving this problem results in "Improperly Constructed Page Tree" being returned by JHOVE. This seems to be being caused by JHOVE not correctly setting the object index for objects extracted from streams, meaning that when PageTreeNode.nextPageObject (line 197) tries to check if it's already visited a node, it fails (essentially it compares index -1 to index -1).