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

Prevent stack overflows by limiting recursion #501

Closed
wants to merge 1 commit into from

Commits on Jun 6, 2022

  1. Add a recursion limit to prevent stack overflows

    Until now, it's been able to trigger a stack overflow crash by providing a
    string with excessive recursion. For instance a string of 1000 left brackets
    causes the parser to recurse down 1000 times, and overflow the stack.
    
    This commit adds protection against excessive recursion. It adds a field to
    `Parser` for tracking the current recursion depth. Every function that returns
    a `Result` gains a recursion depth check. This isn't quite every method on the
    `Parser`, but it's the vast majority.
    
    An alternative implemention would be to only protect against AST recursions,
    rather than recursive function calls in `Parser`. That isn't as easy to implement
    because the parser is so large.
    46bit committed Jun 6, 2022
    Configuration menu
    Copy the full SHA
    dc4127c View commit details
    Browse the repository at this point in the history