summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2010-12-11 18:39:27 (GMT)
committerKevin B Kenny <kennykb@acm.org>2010-12-11 18:39:27 (GMT)
commitfbefb585cb3784a6afcfa775c2c0554e4036f907 (patch)
treefe86a2d97e77053d9c344bfd81ded64a9bdc7f9f /generic/tclUtil.c
parent921c2612861d68b7b4eee66736379431ac081f30 (diff)
downloadtcl-fbefb585cb3784a6afcfa775c2c0554e4036f907.zip
tcl-fbefb585cb3784a6afcfa775c2c0554e4036f907.tar.gz
tcl-fbefb585cb3784a6afcfa775c2c0554e4036f907.tar.bz2
merge
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 4e43176..2e435e6 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.117.2.2 2010/12/01 16:42:36 kennykb Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.117.2.3 2010/12/11 18:39:29 kennykb Exp $
*/
#include "tclInt.h"
@@ -2527,7 +2527,7 @@ TclFormatInt(buffer, n)
long intVal;
int i;
int numFormatted, j;
- char *digits = "0123456789";
+ const char *digits = "0123456789";
/*
* Check first whether "n" is zero.
@@ -3328,7 +3328,7 @@ TclReToGlob(
Tcl_DString *dsPtr,
int *exactPtr)
{
- int anchorLeft, anchorRight, lastIsStar;
+ int anchorLeft, anchorRight, lastIsStar, numStars;
char *dsStr, *dsStrStart;
const char *msg, *p, *strEnd;
@@ -3387,6 +3387,7 @@ TclReToGlob(
p = reStr;
anchorRight = 0;
lastIsStar = 0;
+ numStars = 0;
if (*p == '^') {
anchorLeft = 1;
@@ -3450,6 +3451,7 @@ TclReToGlob(
if (!lastIsStar) {
*dsStr++ = '*';
lastIsStar = 1;
+ numStars++;
}
continue;
} else if (p[1] == '+') {
@@ -3457,6 +3459,7 @@ TclReToGlob(
*dsStr++ = '?';
*dsStr++ = '*';
lastIsStar = 1;
+ numStars++;
continue;
}
}
@@ -3480,6 +3483,15 @@ TclReToGlob(
}
lastIsStar = 0;
}
+ if (numStars > 1) {
+ /*
+ * Heuristic: if >1 non-anchoring *, the risk is large that glob
+ * matching is slower than the RE engine, so report invalid.
+ */
+ msg = "excessive recursive glob backtrack potential";
+ goto invalidGlob;
+ }
+
if (!anchorRight && !lastIsStar) {
*dsStr++ = '*';
}