Artifact
6d48050bb8a68baf033f05d3e3b5975d1cd868074de02859fee204218a292220:
Ticket change
[6d48050bb8]
- New ticket
[7deeddb36f217dac|7deeddb36f] <i>signed integer overflow in Tcl_ScanObjCmd()</i>.
by
chrstphrchvz on
2022-02-16 08:57:16.
D 2022-02-16T08:57:16.788
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment Setting\s<tt>Tcl_WideInt\swideValue</tt>\sto\sthe\shighest\svalue\srepresentable\sby\s<tt>Tcl_WideInt</tt>\sand\sthen\sdoing\s<tt>wideValue++</tt>\sis\ssigned\sinteger\soverflow\s(undefined\sbehavior).\r\n\r\nUBSan\s(<tt>-fsanitize=signed-integer-overflow</tt>)\serror\swhen\s<tt>Tcl_WideInt</tt>\sis\s<tt>long\slong</tt>:\r\n\r\n<blockquote><pre>\r\n%\sscan\s-0x18000000000000000\s{%li}\r\n<span\sstyle="font-weight:bold">tcl/generic/tclScan.c:926:13:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s9223372036854775807\s+\s1\scannot\sbe\srepresented\sin\stype\s'long\slong\sint'</span>\r\n-9223372036854775808\r\n</pre></blockquote>\r\n\r\nLikewise\swhen\s<tt>Tcl_WideInt</tt>\sis\s<tt>long</tt>:\r\n\r\n<blockquote><pre>\r\n%\sscan\s-0x18000000000000000\s{%li}\r\n<span\sstyle="font-weight:bold">tcl/generic/tclScan.c:926:13:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s9223372036854775807\s+\s1\scannot\sbe\srepresented\sin\stype\s'Tcl_WideInt'\s(aka\s'long')</span>\r\n-9223372036854775808\r\n</pre></blockquote>\r\n\r\nIncrement\sonly\safter\scasting\sto\s<tt>Tcl_WideUInt</tt>\sif\swraparound\sbehavior\sis\sdesired\s(without\se.g.\s<tt>-fwrapv</tt>);\ssee\sattached\spatch.
J foundin core-8-6-branch
J is_private 0
J login chrstphrchvz
J priority 5\sMedium
J resolution None
J severity Minor
J status Open
J submitter chrstphrchvz
J subsystem 23.\s[scan]
J title signed\sinteger\soverflow\sin\sTcl_ScanObjCmd()
J type Patch
K 7deeddb36f217dac87bc68cb69718a89e3c7d5d7
U chrstphrchvz
Z a244c019c18cb14292d02b3dd7eac5bb