summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1998-07-09 14:47:25 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-07-11 23:43:37 +0000
commit2cd61cdbd64958437da8294b84109bc8b63ab360 (patch)
treec77caa477be19c09cbca09e677a56b48de14cce2 /regcomp.c
parent1e509ade7aa6b4feabef1bbe58cd68a39b4085af (diff)
downloadperl-2cd61cdbd64958437da8294b84109bc8b63ab360.tar.gz
add patch, along with all the missing bits, and doc tweaks
Message-Id: <199807092247.SAA06314@monk.mps.ohio-state.edu> Subject: Re: [PATCH 5.004_71] Secure RE update p4raw-id: //depot/perl@1444
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/regcomp.c b/regcomp.c
index 420d2fb013..3dd95b8e95 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -720,6 +720,7 @@ pregcomp(char *exp, char *xend, PMOP *pm)
regseen = 0;
seen_zerolen = *exp == '^' ? -1 : 0;
+ seen_evals = 0;
extralen = 0;
/* First pass: determine size, legality. */
@@ -787,6 +788,8 @@ pregcomp(char *exp, char *xend, PMOP *pm)
regnaughty = 0;
regnpar = 1;
regcode = r->program;
+ /* Store the count of eval-groups for security checks: */
+ regcode->next_off = ((seen_evals > U16_MAX) ? U16_MAX : seen_evals);
regc((U8)MAGIC, (char*) regcode++);
r->data = 0;
if (reg(0, &flags) == NULL)
@@ -1059,13 +1062,10 @@ reg(I32 paren, I32 *flagp)
regcomp_rx->data->data[n+2] = (void*)sop;
SvREFCNT_dec(sv);
} else { /* First pass */
- if (curcop == &compiling) {
- if (!(hints & HINT_RE_EVAL))
- FAIL("Eval-group not allowed, use re 'eval'");
- }
- else {
- FAIL("Eval-group not allowed at run time");
- }
+ if (reginterp_cnt < ++seen_evals && curcop != &compiling)
+ /* No compiled RE interpolated, has runtime
+ components ===> unsafe. */
+ FAIL("Eval-group not allowed at runtime, use re 'eval'");
if (tainted)
FAIL("Eval-group in insecure regular expression");
}