From 4f3ba4b9d477365cac08bf7361c31778a497d9ad Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 6 Mar 2022 15:49:31 +0000 Subject: Fix [112e7aa36d]: signed integer overflow in Tcl_SetObjLength(), Tcl_AttemptSetObjLength() --- generic/tclStringObj.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 8f4bfb2..d1e709c 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -956,9 +956,9 @@ Tcl_SetObjLength( * Need to enlarge the buffer. */ if (objPtr->bytes == tclEmptyStringRep) { - objPtr->bytes = (char *)ckalloc(length + 1); + objPtr->bytes = (char *)ckalloc((unsigned int)length + 1U); } else { - objPtr->bytes = (char *)ckrealloc(objPtr->bytes, length + 1); + objPtr->bytes = (char *)ckrealloc(objPtr->bytes, (unsigned int)length + 1U); } stringPtr->allocated = length; } @@ -1062,9 +1062,9 @@ Tcl_AttemptSetObjLength( char *newBytes; if (objPtr->bytes == tclEmptyStringRep) { - newBytes = (char *)attemptckalloc(length + 1); + newBytes = (char *)attemptckalloc((unsigned int)length + 1U); } else { - newBytes = (char *)attemptckrealloc(objPtr->bytes, length + 1); + newBytes = (char *)attemptckrealloc(objPtr->bytes, (unsigned int)length + 1U); } if (newBytes == NULL) { return 0; -- cgit v0.12 From 9a091756bbc40e8d359ac59e4b892c0835f57bae Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 6 Mar 2022 16:10:06 +0000 Subject: Fix [4789e18fcb]: signed integer overflow during obj-31.6 --- generic/tclUtil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 858163e..8d2347b 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3730,7 +3730,8 @@ UpdateStringOfEndOffset( memcpy(buffer, "end", 4); if (objPtr->internalRep.longValue != 0) { buffer[len++] = '-'; - len += TclFormatInt(buffer+len, -(objPtr->internalRep.longValue)); + len += TclFormatInt(buffer+len, + (long)(-(unsigned long)(objPtr->internalRep.longValue))); } objPtr->bytes = (char *)ckalloc(len+1); memcpy(objPtr->bytes, buffer, len+1); @@ -3842,8 +3843,7 @@ SetEndOffsetFromAny( } if (bytes[3] == '-') { - /* TODO: Review overflow concerns here! */ - offset = -offset; + offset = (int)(-(unsigned int)offset); } } else { /* -- cgit v0.12 From 2071722ddec667bebfb47e91d684cc37be2d81e5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 7 Mar 2022 21:45:10 +0000 Subject: Improve a bit the ttk::treeview man page by instructing the html generator not link some words in that page when it should not. --- tools/tcltk-man2html.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 020aad9..75ed97e 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -682,7 +682,7 @@ array set exclude_refs_map { ttk_scale.n {variable} ttk_scrollbar.n {set} ttk_spinbox.n {format} - ttk_treeview.n {text open} + ttk_treeview.n {text open focus selection} ttk_widget.n {image text variable} TclZlib.3 {binary flush filename text} } -- cgit v0.12 From faf33c3ece8ecb7a33845cb5c3b4edfd725b9ef3 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 7 Mar 2022 23:59:52 +0000 Subject: Starting in Tcl 8.7, Tcl_GetUniChar() returns int, not Tcl_UniChar (TIP 389). Make typecasts of returned values match the new signature. --- generic/tclStringObj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 0a6503c..c2249ae 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -561,7 +561,7 @@ Tcl_GetUniChar( TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length); } if (stringPtr->numChars == objPtr->length) { - return (Tcl_UniChar) objPtr->bytes[index]; + return (int) objPtr->bytes[index]; } FillUnicodeRep(objPtr); stringPtr = GET_STRING(objPtr); -- cgit v0.12 From 0c1dd51a1481431e5ea33b1a451b99c939775ea8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 8 Mar 2022 08:23:07 +0000 Subject: This typecast is wrong (and was already wrong). Correct it, and add testcase to prove it --- generic/tclStringObj.c | 2 +- tests/string.test | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index c2249ae..7d4aef3 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -561,7 +561,7 @@ Tcl_GetUniChar( TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length); } if (stringPtr->numChars == objPtr->length) { - return (int) objPtr->bytes[index]; + return (unsigned char) objPtr->bytes[index]; } FillUnicodeRep(objPtr); stringPtr = GET_STRING(objPtr); diff --git a/tests/string.test b/tests/string.test index 7da50e9..203d0c6 100644 --- a/tests/string.test +++ b/tests/string.test @@ -510,6 +510,9 @@ test string-5.20.$noComp {string index, bytearray object out of bounds} -body { test string-5.21.$noComp {string index, surrogates, bug [11ae2be95dac9417]} -constraints utf16 -body { run {list [string index a\U100000b 1] [string index a\U100000b 2] [string index a\U100000b 3]} } -result [list \U100000 {} b] +test string-5.22.$noComp {string index} -constraints testbytestring -body { + run {list [scan [string index [testbytestring \xFF] 0] %c var] $var} +} -result {1 255} test string-6.1.$noComp {string is, not enough args} { -- cgit v0.12