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

feat: resolving invalid parsing causing stack overflow #280

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

galkahana
Copy link
Owner

This is intended as resolution to #278 and #279.
Both issues report test files that when parsed cause a stack overflow.
The stack overflow is set up by providing many multiple array start char - [ - or dict start chars - << . Each such start triggers a new recursion level at the object parser looking to parse the items of the array or dict. when in themselves they are arrays or dicts (by having that starter token) there's another level...and another...and another.

I put a max depth, of either dicts or arrays parsing at 100. This includes resolving cases of such sequences that intermingle array and dict start like <<[<<[<<[[[[<<[<<<<[. If there's a depth of 100 of either dicts or arrays including each other the code will halt parsing with a failure and return. This limit should take any valid PDF and parse it well, and stop naughty PDFs.

@galkahana galkahana merged commit 579d703 into master Aug 21, 2024
7 checks passed
@galkahana galkahana deleted the galk.pdfwriter.fuzz_parsing_object_depth branch August 21, 2024 17:50
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.

1 participant