Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9241e84ed8c89875e507047788c734a41dc53956ae873c3c20b24030539d14a0
Ticket: 112e7aa36dbfc3e12be9b32968593729ca6f6264
signed integer overflow in Tcl_SetObjLength(), Tcl_AttemptSetObjLength()
User & Date: chrstphrchvz on 2022-03-05 22:48:06
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Calling <tt>Tcl_SetObjLength(…, INT_MAX)</tt> or <tt>Tcl_AttemptSetObjLength(…, INT_MAX)</tt> leads to signed integer overflow. The attached patch avoids this.
    
    Example UBSan error:
    <pre>
    <span style="font-weight:bold">tcl/generic/tclStringObj.c:961:27:<span style="color:red"> runtime error: </span>signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'</span>
    </pre>
    
    Example test case to add to stringObj.test (likely not desirable for Tcl to adopt—will panic on systems with insufficient memory):
    <pre>
    test stringObj-4.99 {Tcl_SetObjLength procedure, string lengthened to INT_MAX} testobj {
        testobj freeallvars
        teststringobj set 1 abcdef
        teststringobj setlength 1 &#91;expr 2**31-1&#93;
        list &#91;teststringobj length 1&#93;
    } &#91;list &#91;expr 2**31-1&#93;&#93;
    </pre>
    
  5. foundin changed to: "core-8-6-branch"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "chrstphrchvz"
  13. subsystem changed to: "10. Objects"
  14. title changed to:
    signed integer overflow in Tcl_SetObjLength(), Tcl_AttemptSetObjLength()
    
  15. type changed to: "Patch"