summaryrefslogtreecommitdiffstats
path: root/win/tkWinWm.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-12-06 10:30:49 (GMT)
committernijtmans <nijtmans>2010-12-06 10:30:49 (GMT)
commit145990da784cdcc5cad752ea8a9b6c9d7993a4a5 (patch)
tree30f68715fe0ee4a093c81502fb5921d24507a4cf /win/tkWinWm.c
parentcd230a0b288f0edcbccd62710fe5c95261c83b2e (diff)
downloadtk-145990da784cdcc5cad752ea8a9b6c9d7993a4a5.zip
tk-145990da784cdcc5cad752ea8a9b6c9d7993a4a5.tar.gz
tk-145990da784cdcc5cad752ea8a9b6c9d7993a4a5.tar.bz2
[Bug 3129527]: Fix buffer overflow w/ GCC 4.5 and -D_FORTIFY_SOURCE=2
Diffstat (limited to 'win/tkWinWm.c')
-rw-r--r--win/tkWinWm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 9428444..94c8bb8 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.146 2010/11/29 11:25:09 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.147 2010/12/06 10:30:50 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -60,7 +60,7 @@ typedef struct ProtocolHandler {
* same top-level window, or NULL for end of
* list. */
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[4]; /* Tcl command to invoke when a client message
+ char command[1]; /* Tcl command to invoke when a client message
* for this protocol arrives. The actual size
* of the structure varies to accommodate the
* needs of the actual command. THIS MUST BE
@@ -68,7 +68,7 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
+ ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
/*
* Helper type passed via lParam to TkWmStackorderToplevelEnumProc
@@ -4930,7 +4930,7 @@ WmProtocolCmd(
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
protPtr->interp = interp;
- strcpy(protPtr->command, cmd);
+ memcpy(protPtr->command, cmd, cmdLength + 1);
}
return TCL_OK;
}