Tcl Source Code

View Ticket
Login
Ticket UUID: 74cc95b563dd5450eac9e0ea9c8ad1e4273c9d41
Title: UpdateStringOfDict(): signed integer overflow
Type: Patch Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2022-10-04 06:31:42
Subsystem: 15. Dict Object Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-10-06 10:24:16
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2022-10-06 10:24:16
Description:

…which these example scripts trigger and the attached patch prevents:

  • # s has string representation with length INT_MAX-1
    set s [string repeat [string repeat {a} 14949] 143654]
    set d1 [dict create aa $s]
    puts [string is upper $d1]
    
    tcl/generic/tclDictObj.c:539:14: runtime error: signed integer overflow: 2 + 2147483646 cannot be represented in type 'int'
    max size for a Tcl value (2147483647 bytes) exceeded
    
    (tclsh aborts)
  • # s has string representation with length INT_MAX-1
    set s [string repeat [string repeat {a} 14949] 143654]
    set d2 [dict create a $s z {}]
    puts [string is upper $d2]
    
    tcl/generic/tclDictObj.c:531:14: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
    max size for a Tcl value (2147483647 bytes) exceeded
    
    (tclsh aborts)

User Comments: jan.nijtmans added on 2022-10-06 10:24:16:

Should be fixed [0e2b23ff845b1e1b|here]


Attachments: