summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-08-14 15:10:22 +1000
committerZefram <zefram@fysh.org>2017-12-06 22:07:56 +0000
commit6c4f4eb174d1e2e9f874786123a699d11ae741f9 (patch)
treede2544f5117da6cd940129439c791427e1fb384c /regcomp.c
parent1af9149031d9f5d2d43b6df59b628a0f2c1041f6 (diff)
downloadperl-6c4f4eb174d1e2e9f874786123a699d11ae741f9.tar.gz
prevent integer overflow when compiling a regexp
Fixes [perl #131893].
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/regcomp.c b/regcomp.c
index fcedc3629f..c01fec6fe6 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5941,8 +5941,12 @@ Perl_re_printf( aTHX_ "LHS=%" UVuf " RHS=%" UVuf "\n",
data->cur_is_floating = 1; /* float */
}
min += min1;
- if (delta != SSize_t_MAX)
- delta += max1 - min1;
+ if (delta != SSize_t_MAX) {
+ if (SSize_t_MAX - (max1 - min1) >= delta)
+ delta += max1 - min1;
+ else
+ delta = SSize_t_MAX;
+ }
if (flags & SCF_DO_STCLASS_OR) {
ssc_or(pRExC_state, data->start_class, (regnode_charclass *) &accum);
if (min1) {