We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98f7401 commit 162ee5fCopy full SHA for 162ee5f
generic/tclBinary.c
@@ -2808,14 +2808,16 @@ BinaryEncodeUu(
2808
}
2809
*cursor++ = UueDigits[lineLen];
2810
for (i = 0 ; i < lineLen ; i++) {
2811
- n <<= 8;
+ /* Left shift cast to unsigned type to prevent UB on overflow */
2812
+ n = (Tcl_Size)((size_t)n << 8);
2813
n |= data[offset++];
2814
for (bits += 8; bits > 6 ; bits -= 6) {
2815
*cursor++ = UueDigits[(n >> (bits - 6)) & 0x3F];
2816
2817
2818
if (bits > 0) {
2819
2820
2821
*cursor++ = UueDigits[(n >> (bits + 2)) & 0x3F];
2822
bits = 0;
2823
0 commit comments