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
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- 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 < argc && argc < 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.
- foundin changed to: "core-8-6-branch"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "14. List Object"
- title changed to:
Tcl_Merge(): out-of-bounds write, more signed integer overflow
- type changed to: "Patch"