Attachment "3129448_2.patch" to
ticket [3129448fff]
added by
nijtmans
2010-12-11 04:56:25.
Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.308
diff -u -r1.308 tcl.h
--- generic/tcl.h 14 Aug 2010 20:58:30 -0000 1.308
+++ generic/tcl.h 10 Dec 2010 21:21:58 -0000
@@ -1165,7 +1165,7 @@
int words[1]; /* Multiple integer words for key. The actual
* size will be as large as necessary for this
* table's keys. */
- char string[4]; /* String for key. The actual size will be as
+ char string[1]; /* String for key. The actual size will be as
* large as needed to hold the key. */
} key; /* MUST BE LAST FIELD IN RECORD!! */
};
Index: generic/tclCkalloc.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCkalloc.c,v
retrieving revision 1.42
diff -u -r1.42 tclCkalloc.c
--- generic/tclCkalloc.c 6 Dec 2010 09:01:49 -0000 1.42
+++ generic/tclCkalloc.c 10 Dec 2010 21:21:58 -0000
@@ -814,6 +814,7 @@
FILE *fileP;
Tcl_DString buffer;
int result;
+ size_t len;
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
@@ -909,9 +910,10 @@
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) {
Index: generic/tclCompile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompile.c,v
retrieving revision 1.193
diff -u -r1.193 tclCompile.c
--- generic/tclCompile.c 20 Oct 2010 20:52:27 -0000 1.193
+++ generic/tclCompile.c 10 Dec 2010 21:21:59 -0000
@@ -2600,8 +2600,7 @@
if (create || (name == NULL)) {
localVar = procPtr->numCompiledLocals;
localPtr = (CompiledLocal *) ckalloc((unsigned)
- (sizeof(CompiledLocal) - sizeof(localPtr->name)
- + nameBytes + 1));
+ (TclOffset(CompiledLocal, name) + nameBytes + 1));
if (procPtr->firstLocalPtr == NULL) {
procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr;
} else {
@@ -4404,7 +4403,7 @@
}
len = strlen(s);
objPtr->bytes = ckalloc((unsigned) len + 1);
- strcpy(objPtr->bytes, s);
+ memcpy(objPtr->bytes, s, len + 1);
objPtr->length = len;
}
Index: generic/tclHash.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclHash.c,v
retrieving revision 1.47
diff -u -r1.47 tclHash.c
--- generic/tclHash.c 1 Dec 2010 09:58:52 -0000 1.47
+++ generic/tclHash.c 10 Dec 2010 21:21:59 -0000
@@ -829,14 +829,14 @@
{
const char *string = (const char *) keyPtr;
Tcl_HashEntry *hPtr;
- unsigned int size;
+ unsigned int size, allocsize;
- size = sizeof(Tcl_HashEntry) + strlen(string) + 1 - sizeof(hPtr->key);
- if (size < sizeof(Tcl_HashEntry)) {
- size = sizeof(Tcl_HashEntry);
+ allocsize = size = strlen(string) + 1;
+ if (size < sizeof(hPtr->key)) {
+ allocsize = sizeof(hPtr->key);
}
- hPtr = (Tcl_HashEntry *) ckalloc(size);
- strcpy(hPtr->key.string, string);
+ hPtr = (Tcl_HashEntry *) ckalloc(TclOffset(Tcl_HashEntry, key) + allocsize);
+ memcpy(hPtr->key.string, string, size);
hPtr->clientData = 0;
return hPtr;
}
Index: generic/tclIO.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.h,v
retrieving revision 1.17
diff -u -r1.17 tclIO.h
--- generic/tclIO.h 20 Mar 2010 15:39:46 -0000 1.17
+++ generic/tclIO.h 10 Dec 2010 21:21:59 -0000
@@ -65,13 +65,13 @@
int bufLength; /* How big is the buffer? */
struct ChannelBuffer *nextPtr;
/* Next buffer in chain. */
- char buf[4]; /* Placeholder for real buffer. The real
- * buffer occuppies this space + bufSize-4
+ char buf[1]; /* Placeholder for real buffer. The real
+ * buffer occuppies this space + bufSize-1
* bytes. This must be the last field in the
* structure. */
} ChannelBuffer;
-#define CHANNELBUFFER_HEADER_SIZE (sizeof(ChannelBuffer) - 4)
+#define CHANNELBUFFER_HEADER_SIZE TclOffset(ChannelBuffer, buf)
/*
* How much extra space to allocate in buffer to hold bytes from previous
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.489
diff -u -r1.489 tclInt.h
--- generic/tclInt.h 9 Dec 2010 15:09:08 -0000 1.489
+++ generic/tclInt.h 10 Dec 2010 21:21:59 -0000
@@ -954,7 +954,7 @@
* is marked by a unique ClientData tag during
* compilation, and that same tag is used to
* find the variable at runtime. */
- char name[4]; /* Name of the local variable starts here. If
+ char name[1]; /* Name of the local variable starts here. If
* the name is NULL, this will just be '\0'.
* The actual size of this field will be large
* enough to hold the name. MUST BE THE LAST
Index: generic/tclProc.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclProc.c,v
retrieving revision 1.182
diff -u -r1.182 tclProc.c
--- generic/tclProc.c 27 Sep 2010 19:42:38 -0000 1.182
+++ generic/tclProc.c 10 Dec 2010 21:21:59 -0000
@@ -622,8 +622,7 @@
*/
localPtr = (CompiledLocal *) ckalloc((unsigned)
- (sizeof(CompiledLocal) - sizeof(localPtr->name)
- + nameLength + 1));
+ (TclOffset(CompiledLocal, name) + nameLength + 1));
if (procPtr->firstLocalPtr == NULL) {
procPtr->firstLocalPtr = procPtr->lastLocalPtr = localPtr;
} else {
@@ -643,7 +642,7 @@
} else {
localPtr->defValuePtr = NULL;
}
- strcpy(localPtr->name, fieldValues[0]);
+ memcpy(localPtr->name, fieldValues[0], nameLength + 1);
if ((i == numArgs - 1)
&& (localPtr->nameLength == 4)
&& (localPtr->name[0] == 'a')