Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c22669188addc70faa14110e4146222f883370f9425279ebc40c66e382b8bfcb
Ticket: 05ff16e799ef5d6d15ad1330425f243e5c49d13f
signed integer overflow in ExtendStringRepWithUnicode()
User & Date: chrstphrchvz on 2022-04-07 18:58:01
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Example script (assumes your Tcl already has the fix for [0e8fd6c6d5]):
    
    <blockquote>
    <pre>
    set z &#91;string repeat "\u0000" 1073741820&#93;
    puts stderr &#91;::tcl::unsupported::representation $z&#93;<br />
    # create string obj with longest possible unicode rep and no string rep
    set zz &#91;string replace $z 0 1 $z&#93;
    puts stderr &#91;::tcl::unsupported::representation $zz&#93;<br />
    # force generating string rep (should abort due to exceeding max size for a Tcl value)
    set ZZ &#91;string toupper $zz&#93;
    puts stderr &#91;::tcl::unsupported::representation $ZZ&#93;
    </pre>
    </blockquote>
    
    Output containing UBSan <tt>-fsanitize=signed-integer-overflow</tt> error (which the attached patch prevents):
    
    <blockquote>
    <pre>
    value is a pure string with a refcount of 2, object pointer at 0x604000041490, string representation "..."
    value is a string with a refcount of 2, object pointer at 0x604000041c10, internal representation 0x316793800:0xbebebebebebebebe, no string representation
    <span style="font-weight:bold">tcl/generic/tclStringObj.c:3344:7: <span style="color:firebrick">runtime error:</span> signed integer overflow: 2147483646 + 2 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>
    (tclsh aborted)
    </blockquote>
    
  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 ExtendStringRepWithUnicode()
    
  15. type changed to: "Patch"