summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixWm.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 /unix/tkUnixWm.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 'unix/tkUnixWm.c')
-rw-r--r--unix/tkUnixWm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index c45d5d5..61b94a7 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.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: tkUnixWm.c,v 1.83 2010/06/15 11:16:02 nijtmans Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.84 2010/12/06 10:30:50 nijtmans Exp $
*/
#include "tkUnixInt.h"
@@ -30,7 +30,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
@@ -38,7 +38,7 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- ((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))
+ ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength))
/*
* Data for [wm attributes] command:
@@ -3028,7 +3028,7 @@ WmProtocolCmd(
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
protPtr->interp = interp;
- strcpy(protPtr->command, cmd);
+ memcpy(protPtr->command, cmd, cmdLength + 1);
}
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdateWmProtocols(wmPtr);