Tcl Source Code

View Ticket
Login
Ticket UUID: d282fcacd1ed9936b62dab381c2fe0d1eae41d3d
Title: signed integer overflow in ScanNumber()
Type: Patch Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2022-02-17 06:17:58
Subsystem: 16. Commands A-H Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-02-23 15:49:34
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2022-02-23 15:49:34
Description:

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.

User Comments: jan.nijtmans added on 2022-02-23 15:49:34:

Fixed [d7a73dbf01aedfc5|here]

Thanks for the report and the patch!


Attachments: