Artifacts Associated With Ticket bca10e3790
Ticket change [c605a2269e] (rid 196943) by chrstphrchvz on 2021-12-28 23:11:04:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
<tt>ResultAdd()</tt> (generic/tclIOGT.c) is sometimes called with <tt>size_t toWrite = 0</tt> and a <tt>ResultBuffer *r</tt> such that <tt>r->buf = NULL</tt>. In this case, <tt>r->used = 0</tt> and <tt>r->allocated = 0</tt>, so <tt>ResultAdd()</tt> will not allocate a new buffer. This leads to <tt>NULL + 0</tt> pointer arithmetic when doing <tt>r->buf + r->used</tt>, and calling <tt>memcpy()</tt> with <tt>NULL</tt> as the destination (even though the copy length <tt>toWrite</tt> is 0), both of which are undefined behavior. [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks|UBSan <tt>-fsanitize=nonnull-attribute</tt> (GCC) and <tt>-fsanitize=pointer-overflow</tt>] errors during test iogt-1.1: <pre> <span style="font-weight:bold">tcl/generic/tclIOGT.c:1445:5: <span style="color:red">runtime error:</span> null pointer passed as argument 1, which is declared to never be null tcl/generic/tclIOGT.c:1445:12: <span style="color:red">runtime error:</span> applying zero offset to null pointer</span> </pre>
- 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: "52. Portability Support"
- title initialized to: "Undefined behavior in ResultAdd()"
- type initialized to: "Bug"
Ticket change [4551874dfa] (rid 197039) by jan.nijtmans on 2022-01-13 11:41:58:
- assignee changed to: "jan.nijtmans"
- icomment:
Suggested fix [acb2cec2bd31723a|here]. This also makes various functions in tclIOGT.c and tclIOTrans.c equal (since the ResultAdd() function in tclIOTrans.c didn't have this problem)
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
Ticket change [b367cfe4e4] (rid 197091) by jan.nijtmans on 2022-01-14 22:49:53:
- closedate changed to: "2459594.4513112"
- closer changed to: "jan.nijtmans"
- login: "jan.nijtmans"
- mimetype: "text/plain"
- status changed to: "Closed"