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

SP-3760 Guard against infinite loop page trees #4

Merged
merged 1 commit into from
Sep 26, 2019

Conversation

jonls
Copy link

@jonls jonls commented Sep 26, 2019

Guard against infinite loops in the page tree.

I've not been able to find any PDFs with deeper nesting than 10 but someone in pdfrw issues mentioned that a particular tool was creating a subtree for each page so depth would be equal to the number of pages. This seems to be rare though and I've set the max depth to 50000 so I think it should be unlikely to run into this threshold.

Another solution would be to keep track of all Pages objects that have been seen already (this is what poppler does) which means we could instantly detect cycles. This would be relatively easy if we could tell the object number but I don't think it's possible with pdfrw.

Testing:

JIRA Tickets
SP-3760

@jonls jonls requested a review from hyangda September 26, 2019 21:43
@ghost ghost assigned hyangda Sep 26, 2019
Copy link

@hyangda hyangda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, maybe we can look into keeping track of seen objects in the master repo for Hacktoberfest :bowtie:

@jonls jonls merged commit faa9c2d into master Sep 26, 2019
@jonls jonls deleted the sp-3760-fix-infinite-loop branch September 26, 2019 22:20
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 this pull request may close these issues.

2 participants