Skip to content
Tcl Source Code View Ticket
Login

View Ticket

signed integer overflow in ScanNumber()

Closed / Fixedd282fcacd1ed9936b62dab381c2fe0d1eae41d3dCreated 5 years agoUpdated 5 years ago
Descriptionwiki2022-02-17 06:17:58
UBSan (-fsanitize=shift-base) errors for 32-bit long:
% binary scan \x00\x00\x00\x80 i myvar
tcl/generic/tclBinary.c:2105:28: runtime error: left shift of 128 by 24 places cannot be represented in type 'long int'
1
% binary scan \x80\x00\x00\x00 I myvar
tcl/generic/tclBinary.c:2110:29: runtime error: left shift of 128 by 24 places cannot be represented in type 'long int'
1

This can be avoided by casting at least the most significant source byte to unsigned long before shifting; see attached patch.

Referenced by1
jan.nijtmanswiki2022-02-23 15:49:34

Fixed [here]

Thanks for the report and the patch!

Log in (anonymous is fine) to add a comment.