|
2023-04-23
| ||
| 05:23 | Merge 8.7 - [d90fee06d0] (lassign) and [203792a48c] (Utf32ToUtf) check-in: 8b91a4a3c6 user: apnadkarni tags: trunk, main | |
|
2023-04-22
| ||
| 18:10 | • Closed ticket [203792a48c]: Avoid signed integer overflow in Utf32ToUtfProc()</i... artifact: caa8aaf160 user: jan.nijtmans | |
| 17:55 | Fix [203792a48c]: Avoid signed integer overflow in Utf32ToUtfProc() check-in: 071ea1adbf user: jan.nijtmans tags: core-8-branch | |
| 08:05 | • New ticket [203792a48c] Avoid signed integer overflow in Utf32ToUtfProc(). artifact: 48bb1e2e08 user: chrstphrchvz | |
Avoid signed integer overflow in Utf32ToUtfProc()
Closed / Fixed203792a48c2fbb32f822d8b0a66f7d8fac3e7981Created 4 years agoUpdated 4 years ago
Descriptionwiki2023-04-22 08:05:33
Encountered during cmdAH.test and encoding.test for Tcl built with -fsanitize=shift-base:
generic/tclEncoding.c:2779:27: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
Avoid by casting to unsigned before shifting:
--- generic/tclEncoding.c.orig
+++ generic/tclEncoding.c
@@ -2774,9 +2774,9 @@ Utf32ToUtfProc(
int prev = ch;
if (flags & TCL_ENCODING_LE) {
- ch = (src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 | (src[1] & 0xFF) << 8 | (src[0] & 0xFF);
+ ch = (unsigned int)(src[3] & 0xFF) << 24 | (src[2] & 0xFF) << 16 | (src[1] & 0xFF) << 8 | (src[0] & 0xFF);
} else {
- ch = (src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
+ ch = (unsigned int)(src[0] & 0xFF) << 24 | (src[1] & 0xFF) << 16 | (src[2] & 0xFF) << 8 | (src[3] & 0xFF);
}
if (HIGH_SURROGATE(prev) && !LOW_SURROGATE(ch)) {
/* Bug [10c2c17c32]. If Hi surrogate not followed by Lo surrogate, finish 3-byte UTF-8 */
Referenced by2
8b91a4a3c6Merge 8.7 - [d90fee06d0] (lassign) and [203792a48c] (Utf32ToUtf) check-in2023-04-23 05:23:01071ea1adbfFix [203792a48c]: Avoid signed integer overflow in Utf32ToUtfProc() check-in2023-04-22 17:55:36
jan.nijtmanswiki2023-04-22 18:10:27
Thanks for the fix!. Closing
Log in (anonymous is fine) to add a comment.