Tcl Source Code

View Ticket
Login
2026-10-17
08:44 • Ticket [ce4483c2cb] Audit GetFormatSpec for size_t status still Open with 4 ... artifact: 7185c84cc3 user: serhiy.storchaka
08:44 • Ticket [2788582fff] binary ugly formatSpec parsing status still Open with ... artifact: 370117495b user: serhiy.storchaka
08:43
Fix [2788582fff] and [ce4483c2cb]: [binary format] with huge counts or offsets panicked or returned ... leaf check-in: dd5cd86e81 user: serhiy.storchaka tags: binary-format-size-overflow
2022-03-11
21:13 • New ticket [ce4483c2cb] Audit GetFormatSpec for size_t. artifact: 0a4bc9c264 user: dgp

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.*.