Artifacts Associated With Ticket 3837178c25
Ticket change [01c37693a7] (rid 214673) by chrstphrchvz on 2023-05-07 02:39:51:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
<tt>Tcl_DStringSetLength()</tt> previously treated negative <tt>length</tt> as 0 (an undocumented behavior some found concerning: [2613599]). The check for negative <tt>length</tt> was removed when TIP 494 made <tt>length</tt> unsigned (originally in [6d05288cf774], partially restored in [c0829cbacc86], and removed again in [84a5f246b739]). TIP 660 changed <tt>length</tt> back to signed without restoring the check for negative <tt>length</tt>, which at a minimum allows writing <tt>'\0'</tt> out-of-bounds. Please consider adding the following (or similar) to tests/dstring.test in all maintained branches, regardless of what is done about this ticket: <blockquote><pre> test dstring-4.3 {truncation} -constraints testdstring -setup { testdstring free } -body { testdstring append "xwvut" -1 # Pass a negative length to Tcl_DStringSetLength(); # if not caught, causing '\0' to be written out-of-bounds, # try corrupting dsPtr->length which begins # 2*sizeof(Tcl_Size) bytes before dsPtr->staticSpace[], # so that the result is -256 (on little endian systems) # rather than e.g. -8 or -16. # (sizeof(Tcl_Size) does not seem to be available via Tcl, # so assume sizeof(Tcl_Size) == sizeof(void*) for Tcl 9.) testdstring trunc [expr {-2*([package vsatisfies $tcl_version 9.0-] ? $tcl_platform(pointerSize) : 4)}] list [testdstring get] [testdstring length] } -cleanup { testdstring free } -result {{} 0} </pre></blockquote> - foundin initialized to: "trunk"
- is_private initialized to: "0"
- login: "chrstphrchvz"
- priority initialized to: "5 Medium"
- private_contact initialized to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "chrstphrchvz"
- subsystem initialized to: "11. Conversions from String"
- title initialized to:
Tcl_DStringSetObjLength(): TIP 660 out-of-bounds write
- type initialized to: "Bug"
Ticket change [558b262cb0] (rid 214694) by jan.nijtmans on 2023-05-07 20:41:20:
- assignee changed to: "jan.nijtmans"
- icomment:
All branches have this test-case now, and `Tcl_DStringSetLength()` is now restored in 9.0. Thanks! Let's think about it, how it should be
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [e255baf9fb] (rid 215024) by apnadkarni on 2023-05-17 14:17:28:
- icomment:
I think this particular check is already on the [bug-c9663296fd] branch along with other missing overflow checks in the DString code.
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [99e4db7497] (rid 216294) by chrstphrchvz on 2023-07-08 12:00:03:
- icomment:
The check appeared on the bug-c9663296fd branch as part of a merge from main: [b4827791dced] I am fine with this ticket being closed if there is nothing else to do for it. I have not encountered nor looked for similar issues.
- login: "chrstphrchvz"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [993e08e70a] (rid 253775) by apnadkarni on 2026-05-22 10:36:31:
- closedate changed to: "2461182.9420256252"
- closer changed to: "apnadkarni"
- icomment:
Both the check and the test are present in current versions so closing.
- login: "apnadkarni"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"