Tcl Source Code

View Ticket
Login
Ticket UUID: fb4a0a66752423622d38c070f89ad81e3b4c2bb8
Title: signed integer overflow in TclpGetClicks()
Type: Patch Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2022-02-17 00:55:29
Subsystem: 16. Commands A-H Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-02-23 14:16:29
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2022-02-23 14:16:29
Description:

Except for maybe 35 minutes before and after the epoch, there is always signed integer overflow in TclpGetClicks() implementations when long is 32-bit:

% clock clicks
tcl/unix/tclUnixTime.c:152:19: runtime error: signed integer overflow: 1645057584 * 1000000 cannot be represented in type 'long int'
3505507099

The attached patch should avoid this, however I have only tested the case for Unix with gettimeofday(), and not the cases for Unix without gettimeofday() nor Windows without NativeGetMicroseconds().

User Comments: jan.nijtmans added on 2022-02-23 14:16:29:

Fixed [8779e57115edee5c|here]

Thanks for the report and the patch!


Attachments: