Avoid running out of stack space by limiting recursion depth in Parse(...)#5
Avoid running out of stack space by limiting recursion depth in Parse(...)#5sipa merged 1 commit intosipa:masterfrom practicalswift:max-recursion
Conversation
|
Somewhat similar issue in the miniscript implementation in Rust: https://github.com/apoelstra/rust-miniscript/issues/41 |
|
@practicalswift Nice find. It seems that it's impossible to create a valid Miniscript with a nesting depth higher than 402 (any such script will trivially exceed the ops limit of 201), so that seems like a natural limit to pick. Now, those 402 consist of 201 We also need this kind of protection when converting from a Script to a Miniscript, as a similar recursive parser function is used there. For those we probably actually need a limit of 402. |
|
Thanks for clarifying! I'll implement. |
|
@sipa Would you mind re-reviewing the updated version? I'll handle the |
|
ACK |
Avoid running out of stack space by limiting recursion depth in
Parse(...).Before:
After:
There are obviously more than one way to solve this: let me know if another route is preferred.
Will the spec say something that could justify a limitation here?