Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-02-23
15:49 • Closed ticket [d282fcacd1]: signed integer overflow in ScanNumber() plus 7 o... artifact: cb72eff41e user: jan.nijtmans
14:24
Fix [d282fcacd1]: signed integer overflow in ScanNumber() check-in: d7a73dbf01 user: jan.nijtmans tags: core-8-6-branch
2022-02-17
06:18 • Add attachment scannumber.diff to ticket [d282fcacd1] artifact: 8dafa9ce36 user: chrstphrchvz
06:17 • New ticket [d282fcacd1] signed integer overflow in ScanNumber(). artifact: 8543f7b807 user: chrstphrchvz

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.