diff options
| author | nijtmans <nijtmans> | 2011-01-25 15:55:48 (GMT) |
|---|---|---|
| committer | nijtmans <nijtmans> | 2011-01-25 15:55:48 (GMT) |
| commit | 28a03ea31da5f07e45e7bcc19451d440856511ad (patch) | |
| tree | 96fe18903ff9db6bec85728c33200aaca097c9bd /generic/tclHash.c | |
| parent | 3a9b9ebaa3ee461dcd89fc566e710d92305be0b8 (diff) | |
| download | tcl-28a03ea31da5f07e45e7bcc19451d440856511ad.zip tcl-28a03ea31da5f07e45e7bcc19451d440856511ad.tar.gz tcl-28a03ea31da5f07e45e7bcc19451d440856511ad.tar.bz2 | |
[Bug 3129448]: Possible over-allocation on 64-bit platforms, part 2,
backported strcpy->memcpy change but not change in any struct.
Diffstat (limited to 'generic/tclHash.c')
| -rw-r--r-- | generic/tclHash.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c index fa4952a..841df07 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclHash.c,v 1.33.2.2 2010/12/31 17:15:16 nijtmans Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.33.2.3 2011/01/25 15:55:48 nijtmans Exp $ */ #include "tclInt.h" @@ -845,14 +845,14 @@ AllocStringEntry( { 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(sizeof(Tcl_HashEntry) + allocsize - sizeof(hPtr->key)); + memcpy(hPtr->key.string, string, size); hPtr->clientData = 0; return hPtr; } |
