Tcl Source Code

View Ticket
Login
Ticket UUID: ce4483c2cb67f6b3ce417cbf471ead93282d809d
Title: Audit GetFormatSpec for size_t
Type: Bug Created on: 2022-03-11 21:13:34
Submitter: dgp Assigned to: nobody
Subsystem: 12. ByteArray Object Severity: Minor
Priority: 5 Medium Last modified: 2026-10-17 08:44:34
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 9.0.5, 9.1.0
Description:
The GetFormatSpec() routine used in the implementation of
[binary format] and [binary scan] is truncating the parsed
"count" value at INT_MAX (and also using INT_MAX as some kind
of signal of a parsing error??) even though the argument has
been expanded to size_t .  Worth examining to see what is the
best way forward.
User Comments:
serhiy.storchaka added on 2026-10-17 08:44:34:

GetFormatSpec no longer truncates at INT_MAX since 9.0 ([06ceffb2f3]), but BinaryFormatCmd still adds the field sizes without checking for overflow: [binary format x4611686018427387904x4611686018427387904] returns an empty string and [binary format x99999999999999999999] panics (same as [2788582fff]). Proposed fix in branch binary-format-size-overflow: report "max size for a Tcl value exceeded" instead. Tests binary-81.*.