summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-08-31 08:55:32 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-08-31 08:55:32 (GMT)
commit3710a862b304ce13a5d771616b45eaa556f201bc (patch)
treeb89107a81aaee65f22938a9b9f99531a9877eefd /unix
parentb237ee23c355f68d92dccd811aa8bfd6f1ceed05 (diff)
parent34d8945d9d1dbbb3f599cabcad75ec0305f7615d (diff)
downloadtk-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 'unix')
-rw-r--r--unix/tkUnixFont.c8
-rw-r--r--unix/tkUnixSelect.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 1f4a1d4..a6826b5 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -513,7 +513,7 @@ Ucs2beToUtfProc(
srcEnd = src + srcLen;
dstStart = dst;
- dstEnd = dst + dstLen - TCL_UTF_MAX;
+ dstEnd = dst + dstLen - 4;
for (numChars = 0; src < srcEnd; numChars++) {
if (dst > dstEnd) {
@@ -588,7 +588,7 @@ UtfToUcs2beProc(
srcEnd = src + srcLen;
srcClose = srcEnd;
if (!(flags & TCL_ENCODING_END)) {
- srcClose -= TCL_UTF_MAX;
+ srcClose -= 4;
}
dstStart = dst;
@@ -2202,7 +2202,7 @@ FontMapLoadPage(
int row) /* Index of the page to be loaded into the
* cache. */
{
- char buf[16], src[TCL_UTF_MAX];
+ char buf[16], src[4];
int minHi, maxHi, minLo, maxLo, scale, checkLo;
int i, end, bitOffset, isTwoByteFont, n;
Tcl_Encoding encoding;
@@ -2406,7 +2406,7 @@ CanUseFallback(
unsigned bestScore[2];
char **nameList;
char **nameListOrig;
- char src[TCL_UTF_MAX];
+ char src[4];
FontAttributes want, got;
Display *display;
SubFont subFont;
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 4bb462e..53275d1 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -21,7 +21,7 @@ typedef struct ConvertInfo {
* offset of the next chunk of data to
* transfer. */
Tcl_EncodingState state; /* The encoding state needed across chunks. */
- char buffer[TCL_UTF_MAX]; /* A buffer to hold part of a UTF character
+ char buffer[4]; /* A buffer to hold part of a UTF character
* that is split across chunks.*/
} ConvertInfo;
@@ -439,7 +439,7 @@ TkSelPropProc(
* Preserve any left-over bytes.
*/
- if (srcLen > TCL_UTF_MAX) {
+ if (srcLen > 4) {
Tcl_Panic("selection conversion left too many bytes unconverted");
}
memcpy(incrPtr->converts[i].buffer, src, (size_t) srcLen+1);