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

Deeply nested capture groups cause stack overflow #68

Closed
k-takata opened this issue Oct 19, 2016 · 1 comment
Closed

Deeply nested capture groups cause stack overflow #68

k-takata opened this issue Oct 19, 2016 · 1 comment
Labels
bug

Comments

@k-takata
Copy link
Owner

@k-takata k-takata commented Oct 19, 2016

How to reproduce:

from testpy import *
# import onigmo
# set_encoding("UTF-8")
# set_output_encoding()
x2("(" * 32767 + "a" + ")" * 32767, "a", 0, 1)

Related: #18 #24

This also occurs on Oniguruma 6.1.1.
Cc: @kkos

@k-takata k-takata added the bug label Oct 19, 2016
k-takata added a commit that referenced this issue Nov 28, 2016
Our parser uses recursion, so it causes stack overflow when parsing
deeply nested capture groups. E.g.:

  x2("(" * 32767 + "a" + ")" * 32767, "a", 0, 1)

Set a limit for this.
The default value is defined in regint.h:
* DEFAULT_PARSE_DEPTH_LIMIT (Currently 4096)

Also add two APIs to support this:
* onig_get_parse_depth_limit
* onig_set_parse_depth_limit
@k-takata
Copy link
Owner Author

@k-takata k-takata commented Nov 28, 2016

Fixed in devel-6.0 branch with the commit e7a614b.
Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.