diff options
| author | apnadkarni <apnmbx-wits@yahoo.com> | 2025-12-28 05:43:07 (GMT) |
|---|---|---|
| committer | apnadkarni <apnmbx-wits@yahoo.com> | 2025-12-28 05:43:07 (GMT) |
| commit | 162ee5f8818b6ab0e88bf8d713e9ce798d4af94a (patch) | |
| tree | 18226649df5225e783fa801d52776209a507af8c | |
| parent | 98f74013e2f489e289ad1a7da4c87dd9715110b5 (diff) | |
| download | tcl-core-bug-7b46bc7f85.zip tcl-core-bug-7b46bc7f85.tar.gz tcl-core-bug-7b46bc7f85.tar.bz2 | |
Bug [7b46bc7f85] UBSan on binary uuencodecore-bug-7b46bc7f85
| -rw-r--r-- | generic/tclBinary.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 2b15d31..e123513 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2808,14 +2808,16 @@ BinaryEncodeUu( } *cursor++ = UueDigits[lineLen]; for (i = 0 ; i < lineLen ; i++) { - n <<= 8; + /* Left shift cast to unsigned type to prevent UB on overflow */ + n = (Tcl_Size)((size_t)n << 8); n |= data[offset++]; for (bits += 8; bits > 6 ; bits -= 6) { *cursor++ = UueDigits[(n >> (bits - 6)) & 0x3F]; } } if (bits > 0) { - n <<= 8; + /* Left shift cast to unsigned type to prevent UB on overflow */ + n = (Tcl_Size)((size_t)n << 8); *cursor++ = UueDigits[(n >> (bits + 2)) & 0x3F]; bits = 0; } |
