Artifacts Associated With Ticket 1599352cca
Ticket change [f65dc39c7e] (rid 204950) by chrstphrchvz on 2022-10-02 14:04:32:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized 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 initialized to: "core-8-6-branch"
- is_private initialized to: "0"
- login: "chrstphrchvz"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "chrstphrchvz"
- subsystem initialized to: "14. List Object"
- title initialized to:
Tcl_Merge(): out-of-bounds write, more signed integer overflow
- type initialized to: "Patch"
Add attachment "1599352cca83.diff" [baf3c5a6bb] (rid 204952) by chrstphrchvz on 2022-10-02 14:06:20.
Ticket change [9dfc7dd265] (rid 205040) by jan.nijtmans on 2022-10-06 10:23:08:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2459858.93273367"
- closer changed to: "jan.nijtmans"
- icomment: "Should be fixed [0e2b23ff845b1e1b|here]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [6fd5b1699d] (rid 205056) by chrstphrchvz on 2022-10-06 20:06:36:
- closedate changed to: "2459859.33791972"
- closer changed to: "chrstphrchvz"
- icomment:
[0e2b23ff845b] does fix quite a few issues, including some I had suspected or had not yet reported. However there is still the issue of <tt>argc == INT_MAX</tt> leading to an out-of-bounds write. Is this won't-fix for Tcl < 9.0?
- login: "chrstphrchvz"
- mimetype: "text/x-fossil-wiki"
Ticket change [e7689f573f] (rid 205057) by chrstphrchvz on 2022-10-06 20:17:44:
- closedate changed to: "2459859.34565304"
- icomment:
I meant <tt>argc == INT_MIN</tt> in the previous comment.
- login: "chrstphrchvz"
- mimetype: "text/x-fossil-wiki"
Ticket change [19856075b2] (rid 205064) by jan.nijtmans on 2022-10-07 11:20:03:
- closedate changed to: "2459859.97225919"
- closer changed to: "jan.nijtmans"
- icomment: "Should be better now: [63b0443866958521]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"