summaryrefslogtreecommitdiffstats
path: root/generic/tclCkalloc.c
diff options
context:
space:
mode:
authornijtmans <nijtmans@noemail.net>2011-01-25 15:55:47 (GMT)
committernijtmans <nijtmans@noemail.net>2011-01-25 15:55:47 (GMT)
commit55dd464412c4afae80613add51265a33484111cb (patch)
tree96fe18903ff9db6bec85728c33200aaca097c9bd /generic/tclCkalloc.c
parent19e5761ccf0fc4bda84c213f7f8850b2e3a18ef7 (diff)
downloadtcl-55dd464412c4afae80613add51265a33484111cb.zip
tcl-55dd464412c4afae80613add51265a33484111cb.tar.gz
tcl-55dd464412c4afae80613add51265a33484111cb.tar.bz2
[Bug 3129448]: Possible over-allocation on 64-bit platforms, part 2,
backported strcpy->memcpy change but not change in any struct. FossilOrigin-Name: d69078d96b09dd15ff324ce732fc583e8de486a2
Diffstat (limited to 'generic/tclCkalloc.c')
-rw-r--r--generic/tclCkalloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index 27aad95..c7a9757 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -14,7 +14,7 @@
*
* This code contributed by Karl Lehenbauer and Mark Diekhans
*
- * RCS: @(#) $Id: tclCkalloc.c,v 1.32.4.3 2010/10/02 00:29:42 hobbs Exp $
+ * RCS: @(#) $Id: tclCkalloc.c,v 1.32.4.4 2011/01/25 15:55:48 nijtmans Exp $
*/
#include "tclInt.h"
@@ -824,6 +824,7 @@ MemoryCmd(
FILE *fileP;
Tcl_DString buffer;
int result;
+ size_t len;
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
@@ -919,9 +920,10 @@ MemoryCmd(
if ((curTagPtr != NULL) && (curTagPtr->refCount == 0)) {
TclpFree((char *) curTagPtr);
}
- curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(strlen(argv[2])));
+ len = strlen(argv[2]);
+ curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(len));
curTagPtr->refCount = 0;
- strcpy(curTagPtr->string, argv[2]);
+ memcpy(curTagPtr->string, argv[2], len + 1);
return TCL_OK;
}
if (strcmp(argv[1],"trace") == 0) {