summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-05-11 00:47:58 (GMT)
committerhobbs <hobbs>2005-05-11 00:47:58 (GMT)
commit0807771b17f60782e7ee9d2a78400c78e828c336 (patch)
tree20cf32589c9bd8370a01cc925f44664124992138 /generic/tclCmdMZ.c
parent917ad5e5258a380fa7f381264f0f75cb174ab9ec (diff)
downloadtcl-0807771b17f60782e7ee9d2a78400c78e828c336.zip
tcl-0807771b17f60782e7ee9d2a78400c78e828c336.tar.gz
tcl-0807771b17f60782e7ee9d2a78400c78e828c336.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/tclCmdMZ.c')
-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) {