Overview
| Artifact ID: | c605a2269eb376353b9209e66fda2613ac93369192762c3833ee657cbc8f9870 |
|---|---|
| Ticket: | bca10e3790f6c2962c0302d6f62ef9c6fadf5752
Undefined behavior in ResultAdd() |
| User & Date: | chrstphrchvz on 2021-12-28 23:11:04 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed 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 changed to: "8.6.12"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "52. Portability Support"
- title changed to: "Undefined behavior in ResultAdd()"
- type changed to: "Bug"