Artifacts Associated With Ticket 816913a65e
Ticket change [202b980e5b] (rid 196921) by chrstphrchvz on 2021-12-24 19:11:02:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
In <tt>GrowStringBuffer()</tt> (generic/tclStringObj.c), it is possible for <tt>int attempt</tt> to be assigned <tt>INT_MAX</tt>, such as when the function is called with <tt>int needed = INT_MAX</tt>. When this happens, <tt>int attempt</tt> will also be assigned <tt>INT_MAX</tt>, and <tt>attempt + 1</tt> will overflow (although I do not observe this causing unexpected behavior). [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks|UBSan (<tt>-fsanitize=signed-integer-overflow</tt>)] error example: <pre> % set dz [open /dev/zero [list RDONLY]] % set nulls [read $dz [expr {(1 << 30) - 1}]] <span style="font-weight:bold">tcl/generic/tclStringObj.c:167:20: <span style="color:red">runtime error:</span> signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'</span> </pre> If it is indeed okay to allocate <tt>(unsigned int)INT_MAX + 1U</tt>, then some possible ways to avoid overflow include declaring <tt>attempt</tt> as <tt>unsigned int</tt>, or changing instances of <tt>attempt + 1</tt> to promote <tt>attempt</tt> to <tt>unsigned int</tt> (such as by using <tt>attempt + 1U</tt>). - foundin initialized to: "8.6.12"
- 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: "10. Objects"
- title initialized to: "GrowStringBuffer(): signed integer overflow"
- type initialized to: "Bug"
Ticket change [18e29634a5] (rid 197067) by jan.nijtmans on 2022-01-13 17:32:06:
- assignee changed to: "jan.nijtmans"
- icomment: "Possible fix committed [a03e9793d4f70960|here]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
Ticket change [4c61324c39] (rid 197090) by jan.nijtmans on 2022-01-14 22:49:30:
- closedate changed to: "2459594.45104711"
- closer changed to: "jan.nijtmans"
- login: "jan.nijtmans"
- mimetype: "text/plain"
- status changed to: "Closed"