Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f65dc39c7e4e444411b70f5c094ee2b254851b44b84b7d9a70e2f3d56afce870
Ticket: 1599352cca83527b22000b9e6a336fa84344bf61
Tcl_Merge(): out-of-bounds write, more signed integer overflow
User & Date: chrstphrchvz on 2022-10-02 14:04:32
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    Although it only makes sense to provide nonnegative <tt>argc</tt> to  <tt>Tcl_Merge()</tt>, the function is a public API currently making no effort to guard against negative <tt>argc</tt>.
    
    <ul><li>When <tt>argc</tt> is negative, there is signed integer overflow in the expression <tt>INT_MAX - argc + 1</tt>.</li>
    
    <li>(Assuming 32-bit <tt>int</tt>.) If <tt>argc == INT_MIN</tt>, the current behavior is to allocate a 2GiB buffer and then write <tt>'\0'</tt> to the byte prior to the beginning of buffer. Otherwise, if <tt>INT_MIN &lt; argc &amp;&amp; argc &lt; 0</tt>, then the function panics, claiming <tt>max size for a Tcl value (2147483647 bytes) exceeded</tt>.</li></ul>
    
    At a minimum, I would suggest changing the behavior of the function slightly so that it always panics to prevent the out-of-bounds write; panicking is already possible in that case during the <tt>ckalloc(INT_MIN)</tt> call. Maybe a more helpful panic message can be used. See attached patch for a possible solution.
    
  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: "14. List Object"
  14. title changed to:
    Tcl_Merge(): out-of-bounds write, more signed integer overflow
    
  15. type changed to: "Patch"