Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: da0cfb931654cacd95c2432c12851d81f300f502989a79a7399a6690ead1bc26
Ticket: a30d273cfb92ade6065f6265781665920d2d8278
signed integer overflow in TEBCResume() for INST_STR_CONCAT1
User & Date: chrstphrchvz on 2022-02-19 09:06:31
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Example scripts and corresponding output with UBSan (<tt>-fsanitize=signed-integer-overflow</tt>) errors:
    
    <ol><li><pre>
    set f &#91;open /dev/zero &#91;list RDONLY BINARY&#93;&#93;
    fconfigure $f -buffersize &#91;expr {2**20}&#93;
    set z &#91;read $f &#91;expr {2**30}&#93;&#93;
    proc as2 {s} {return &#91;string cat &#91;encoding convertto utf-8 a&#93; $s $s&#93;}
    set az2 &#91;as2 $z&#93;
    </pre>
    <pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2770:17:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 1073741824 + 1073741824 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>(tclsh aborted)</li>
    
    
    <li><pre>
    set a &#91;string repeat &#91;string repeat a &#91;expr {2**10}&#93;&#93; &#91;expr {2**20}&#93;&#93;
    proc us2 {s} {return &#91;string cat {u} $s $s&#93;}
    set ua2 &#91;us2 $a&#93;
    </pre><pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2778:17:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 1073741824 + 1073741824 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>(tclsh aborted)</li>
    
    
    <li><pre>
    set a &#91;string repeat &#91;string repeat a 1023&#93; 1049601&#93;
    proc uus2 {s} {return &#91;string cat {uu} $s $s&#93;}
    set uua2 &#91;uus2 $a&#93;
    </pre>
    <pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2812:17:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 2 + 2147483646 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>(tclsh aborted)</li>
    
    
    <li><pre>
    set a &#91;string repeat &#91;string repeat a 1023&#93; 1049601&#93;
    proc zs2 {s} {return &#91;string cat &#91;expr 0&#93; $s $s&#93;}
    set za2 &#91;zs2 $a&#93;
    </pre>
    <pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2820:25:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'</span>
    </pre>(tclsh exited normally)</li>
    
    
    <li><pre>
    set a &#91;string repeat &#91;string repeat a 1023&#93; 1049601&#93;
    proc us2 {s} {return &#91;string cat {u} $s $s&#93;}
    set ua2 &#91;us2 $a&#93;
    </pre><pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2827:7:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'</span>
    </pre>(tclsh exited normally)</li>
    
    
    <li><pre>
    set f &#91;open /dev/zero &#91;list RDONLY BINARY&#93;&#93;
    fconfigure $f -buffersize &#91;expr {2**20}&#93;
    set z &#91;read $f &#91;expr {2**30}&#93;&#93;
    proc s2 {s} {return &#91;string cat $s $s&#93;}
    set z2 &#91;s2 $z&#93;
    </pre><pre>
    <span style="font-weight:bold">tcl/generic/tclExecute.c:2848:17:<span style="color:firebrick"> runtime error: </span>signed integer overflow: 1073741824 + 1073741824 cannot be represented in type 'int'</span>
    max size for a Tcl value (2147483647 bytes) exceeded
    </pre>(tclsh aborted)</li>
    </ol>
    
    The attached patch prevents these.
    
  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: "18. Commands M-Z"
  14. title changed to:
    signed integer overflow in TEBCResume() for INST_STR_CONCAT1
    
  15. type changed to: "Patch"