Overview
| Artifact ID: | 01c37693a746f7578c165778e0254d4a2e647cecf7dc5b5a9427402e92a25f09 |
|---|---|
| Ticket: | 3837178c2548d802c3946cc0918fedfcf6699e57
Tcl_DStringSetObjLength(): TIP 660 out-of-bounds write |
| User & Date: | chrstphrchvz on 2023-05-07 02:39:51 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed 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 changed to: "trunk"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- private_contact changed to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "11. Conversions from String"
- title changed to:
Tcl_DStringSetObjLength(): TIP 660 out-of-bounds write
- type changed to: "Bug"