Overview
| Artifact ID: | 6d48050bb8a68baf033f05d3e3b5975d1cd868074de02859fee204218a292220 |
|---|---|
| Ticket: | 7deeddb36f217dac87bc68cb69718a89e3c7d5d7
signed integer overflow in Tcl_ScanObjCmd() |
| User & Date: | chrstphrchvz on 2022-02-16 08:57:16 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
Setting <tt>Tcl_WideInt wideValue</tt> to the highest value representable by <tt>Tcl_WideInt</tt> and then doing <tt>wideValue++</tt> is signed integer overflow (undefined behavior). UBSan (<tt>-fsanitize=signed-integer-overflow</tt>) error when <tt>Tcl_WideInt</tt> is <tt>long long</tt>: <blockquote><pre> % scan -0x18000000000000000 {%li} <span style="font-weight:bold">tcl/generic/tclScan.c:926:13:<span style="color:red"> runtime error: </span>signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long long int'</span> -9223372036854775808 </pre></blockquote> Likewise when <tt>Tcl_WideInt</tt> is <tt>long</tt>: <blockquote><pre> % scan -0x18000000000000000 {%li} <span style="font-weight:bold">tcl/generic/tclScan.c:926:13:<span style="color:red"> runtime error: </span>signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'Tcl_WideInt' (aka 'long')</span> -9223372036854775808 </pre></blockquote> Increment only after casting to <tt>Tcl_WideUInt</tt> if wraparound behavior is desired (without e.g. <tt>-fwrapv</tt>); see attached patch. - foundin changed to: "core-8-6-branch"
- 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: "23. [scan]"
- title changed to: "signed integer overflow in Tcl_ScanObjCmd()"
- type changed to: "Patch"