summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-05-11 00:47:58 (GMT)
committerhobbs <hobbs>2005-05-11 00:47:58 (GMT)
commit8bcd5484836bddde955023ae76b23f0a78357033 (patch)
tree20cf32589c9bd8370a01cc925f44664124992138 /generic
parent8875f24d634bf125138e65e7dc33d134f8c8bf32 (diff)
downloadtcl-8bcd5484836bddde955023ae76b23f0a78357033.zip
tcl-8bcd5484836bddde955023ae76b23f0a78357033.tar.gz
tcl-8bcd5484836bddde955023ae76b23f0a78357033.tar.bz2
* tests/string.test: string-10.[21-30]
* generic/tclCmdMZ.c (Tcl_StringObjCmd): add extra checks to prevent possible UMR in unichar cmp function for string map.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 45a2bed..c61afc5 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.16 2005/04/22 16:30:02 dgp Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.17 2005/05/11 00:48:01 hobbs Exp $
*/
#include "tclInt.h"
@@ -1936,7 +1936,8 @@ Tcl_StringObjCmd(dummy, interp, objc, objv)
ustring2 = Tcl_GetUnicodeFromObj(mapElemv[0], &length2);
p = ustring1;
- if (length2 == 0) {
+ if ((length2 > length1) || (length2 == 0)) {
+ /* match string is either longer than input or empty */
ustring1 = end;
} else {
mapString = Tcl_GetUnicodeFromObj(mapElemv[1], &mapLen);
@@ -1994,6 +1995,8 @@ Tcl_StringObjCmd(dummy, interp, objc, objv)
if ((length2 > 0) && ((*ustring1 == *ustring2) ||
(nocase && (Tcl_UniCharToLower(*ustring1) ==
u2lc[index/2]))) &&
+ /* restrict max compare length */
+ ((end - ustring1) >= length2) &&
((length2 == 1) || strCmpFn(ustring2, ustring1,
(unsigned long) length2) == 0)) {
if (p != ustring1) {