Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 58e788fd809be017682fcd86ed7332c66c2671bbb525647911a89f6d6a3dfec5
Ticket: 0e8fd6c6d5fd2f29f90c6e101197796951e399d6
(unsigned)STRING_SIZE(STRING_MAXCHARS) is 0
User & Date: chrstphrchvz on 2022-03-22 02:02:17
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    …causing <tt>stringAlloc(STRING_MAXCHARS)</tt> or similar to eventually lead to a crash or noticeable memory corruption. Example:
    
    <pre>
    set a &#91;string repeat a 1073741820&#93;
    # crash when attempting to create string with longest possible unicode rep and no string rep
    set aa &#91;string replace $a 0 0 $a &#93;
    </pre>
    
    After <tt>TCLFLEXARRAY</tt> ([29540d10c4]) was introduced, <tt>STRING_MAXCHARS</tt> was updated ([3a6a0399ad]), but the <tt>…- 1…</tt> seems to be misplaced (it currently makes no difference in the numerator of the expression): see attached patch. <tt>STRING_MAXCHARS</tt> apparently should return 1 less than what it currently does (i.e. 2147483638 rather than 2147483639, for 32-bit <tt>int</tt> and 16-bit <tt>Tcl_UniChar</tt>).
    
    To my knowledge there are no similar issues for other structures using <tt>TCLFLEXARRAY</tt>.
    
  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: "(unsigned)STRING_SIZE(STRING_MAXCHARS) is 0"
  15. type changed to: "Patch"