Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuilding the object table when offsets are corrupted does not handle missing endobj #893

Closed
Greybird opened this issue Sep 1, 2024 · 0 comments · Fixed by #894
Closed

Comments

@Greybird
Copy link
Contributor

Greybird commented Sep 1, 2024

The BruteForceSearcher allows rebuilding the object offsets table, but once it finds an object declaration, it will not consider new object declaration if not finding endobj beforehand.
Some files are lacking these endobj token on some or all of their object declarations.

It can lead to such an exception:

System.NullReferenceException: Object reference not set to an instance of an object.
    at UglyToad.PdfPig.PdfExtensions.TryGet[T](DictionaryToken dictionary, NameToken name, IPdfTokenScanner tokenScanner, T& token)
    at UglyToad.PdfPig.Content.PagesFactory.CheckIfIsPage(DictionaryToken nodeDictionary, IndirectReference parentReference, Boolean isRoot, IPdfTokenScanner pdfTokenScanner, Boolean isLenientParsing)
    at UglyToad.PdfPig.Content.PagesFactory.ProcessPagesNode(IndirectReference referenceInput, DictionaryToken nodeDictionaryInput, IndirectReference parentReferenceInput, Boolean isRoot, IPdfTokenScanner pdfTokenScanner, Boolean isLenientParsing, PageCounter pageNumber)
    at UglyToad.PdfPig.Content.PagesFactory.Create(IndirectReference pagesReference, DictionaryToken pagesDictionary, IPdfTokenScanner scanner, IPageFactory`1 pageFactory, ILog log, Boolean isLenientParsing)
    at UglyToad.PdfPig.Parser.CatalogFactory.Create(IndirectReference rootReference, DictionaryToken dictionary, IPdfTokenScanner scanner, PageFactory pageFactory, ILog log, Boolean isLenientParsing)
    at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ParsingOptions parsingOptions)
    at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytes inputBytes, ParsingOptions options)
    at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Stream stream, ParsingOptions options)
    at UglyToad.PdfPig.PdfDocument.Open(Stream stream, ParsingOptions options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant