diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-08-31 08:55:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-08-31 08:55:32 (GMT) |
commit | 3710a862b304ce13a5d771616b45eaa556f201bc (patch) | |
tree | b89107a81aaee65f22938a9b9f99531a9877eefd /win | |
parent | b237ee23c355f68d92dccd811aa8bfd6f1ceed05 (diff) | |
parent | 34d8945d9d1dbbb3f599cabcad75ec0305f7615d (diff) | |
download | tk-3710a862b304ce13a5d771616b45eaa556f201bc.zip tk-3710a862b304ce13a5d771616b45eaa556f201bc.tar.gz tk-3710a862b304ce13a5d771616b45eaa556f201bc.tar.bz2 |
Fix use of XMaxTransChars in stead of TCL_UTF_MAX in some places. This should prevent possible buffer overflow when TCL_UTF_MAX=6
Micro-optimizations in tkEntry and ttkEntry
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinFont.c | 2 | ||||
-rw-r--r-- | win/tkWinKey.c | 4 | ||||
-rw-r--r-- | win/tkWinX.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 7b5e4c9..10ea1b9 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2188,7 +2188,7 @@ FontMapLoadPage( { FontFamily *familyPtr; Tcl_Encoding encoding; - char src[TCL_UTF_MAX], buf[16]; + char src[XMaxTransChars], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; diff --git a/win/tkWinKey.c b/win/tkWinKey.c index ed546f7..5591133 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -102,7 +102,7 @@ TkpGetString( */ int unichar; - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; unichar = keyEv->trans_chars[1] & 0xff; @@ -129,7 +129,7 @@ TkpGetString( if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256)) || (keysym == XK_Return) || (keysym == XK_Tab)) { - char buf[TCL_UTF_MAX]; + char buf[XMaxTransChars]; int len; len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf); diff --git a/win/tkWinX.c b/win/tkWinX.c index 7e25826..21c607c 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1215,13 +1215,13 @@ GenerateXEvent( break; case WM_UNICHAR: { - char buffer[TCL_UTF_MAX+1]; + char buffer[XMaxTransChars]; int i; event.type = KeyPress; event.xany.send_event = -3; event.xkey.keycode = wParam; event.xkey.nbytes = Tcl_UniCharToUtf((int)wParam, buffer); - for (i=0; i<event.xkey.nbytes && i<TCL_UTF_MAX; ++i) { + for (i=0; i<event.xkey.nbytes && i<XMaxTransChars; ++i) { event.xkey.trans_chars[i] = buffer[i]; } Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); |