Tcl Source Code

Artifact [3770deb505]
Login

Artifact 3770deb5051f331c356c7ef04c744eca065c5f72:

Attachment "714106.strrepeat" to ticket [714106ffff] added by hobbs 2003-05-11 06:57:38.
Index: generic/tclCmdMZ.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdMZ.c,v
retrieving revision 1.82.2.3
diff -u -b -u -r1.82.2.3 tclCmdMZ.c
--- generic/tclCmdMZ.c	11 Apr 2003 20:49:53 -0000	1.82.2.3
+++ generic/tclCmdMZ.c	10 May 2003 23:45:49 -0000
@@ -2104,8 +2104,17 @@
 		     * Only build up a string that has data.  Instead of
 		     * building it up with repeated appends, we just allocate
 		     * the necessary space once and copy the string value in.
+		     * Check for overflow with back-division. [Bug #714106]
 		     */
 		    length2		= length1 * count;
+		    if ((length2 / count) != length1) {
+			char buf[TCL_INTEGER_SPACE+1];
+			sprintf(buf, "%d", INT_MAX);
+			Tcl_AppendStringsToObj(resultPtr,
+				"string size overflow, must be less than ",
+				buf, (char *) NULL);
+			return TCL_ERROR;
+		    }
 		    /*
 		     * Include space for the NULL
 		     */