diff options
| author | K.Takata <kentkt@csc.jp> | 2019-07-29 20:16:46 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-01-12 20:01:43 +0900 |
| commit | ac379278e818eb92e87a8f82e6841d7ab59baeb2 (patch) | |
| tree | d64e00c390994ff80998e0d09f6c87fa936e8c41 | |
| parent | f0b31a5898ae8101286dc47085139c56ba0bda54 (diff) | |
[k-takata/Onigmo] Fix stack overflow with X+++++++++++++++++++…
Imported the fix from:
https://github.com/kkos/oniguruma/commit/4097828d7cc87589864fecf452f2cd46c5f37180
https://github.com/k-takata/Onigmo/commit/786b4849c1
| -rw-r--r-- | regparse.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/regparse.c b/regparse.c index 1772196bcd..123b3015a5 100644 --- a/regparse.c +++ b/regparse.c @@ -6313,11 +6313,14 @@ parse_exp(Node** np, OnigToken* tok, int term, int r, len, group = 0; Node* qn; Node** targetp; + unsigned int parse_depth; *np = NULL; if (tok->type == (enum TokenSyms )term) goto end_of_token; + parse_depth = env->parse_depth; + switch (tok->type) { case TK_ALT: case TK_EOT: @@ -6628,6 +6631,10 @@ parse_exp(Node** np, OnigToken* tok, int term, if (is_invalid_quantifier_target(*targetp)) return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID; + parse_depth++; + if (parse_depth > ParseDepthLimit) + return ONIGERR_PARSE_DEPTH_LIMIT_OVER; + qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper, (r == TK_INTERVAL ? 1 : 0)); CHECK_NULL_RETURN_MEMERR(qn); |
