Skip to content
Tcl Source Code Artifact [2bba8435d8]
Login

Artifact [2bba8435d8]

Artifact 2bba8435d878ffc8060c701b4a58611b079f140842db599c0263162639628a4e:

Ticket change [2bba8435d8] - New ticket [7f8a3d981843fe53|7f8a3d9818] <i>signed integer overflow in tclExecute.c</i>. by chrstphrchvz on 2022-02-15 22:46:40.
D 2022-02-15T22:46:40.367
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment tclExecute.c\stries\sto\scheck\sfor\ssigned\sinteger\soverflow\safter\sthe\sfact\susing\sthe\s<tt>Overflowing()</tt>\smacro,\sbut\sdoes\snot\savoid\sundefined\sbehavior\sfrom\soccuring\sin\sthe\sexpressions\swhich\soverflow;\scasting\soperands\sto\sunsigned\stypes\savoids\sthis\s(see\sattached\spatch).\r\n\r\nBelow\sare\sexample\striggers\sfor\severy\sinstance\sI\sfound\sand\scorresponding\sUBSan\s(<tt>-fsanitize=signed-integer-overflow</tt>)\serrors.\r\n\r\nFor\s32-bit\s<tt>long</tt>\sand\s64-bit\s<tt>long\slong</tt>:\r\n\r\n<blockquote><pre>\r\n%\sset\sa\s0x7fffffff;\sincr\sa\s1\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:1901:7:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s2147483647\s+\s1\scannot\sbe\srepresented\sin\stype\s'long\sint'</span>\r\n2147483648\r\n%\sproc\se3932\s{}\s{global\sx;\sset\sx\s0x7fffffff;\sincr\sx\s1}\r\n%\se3932\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:3932:12:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s2147483647\s+\s1\scannot\sbe\srepresented\sin\stype\s'long\sint'</span>\r\n%\sproc\se3980_1952\s{}\s{global\sx;\sset\sx\s0x7fffffffffffffff;\sincr\sx\s1}\r\n%\se3980_1952\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:3980:11:<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<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:1952:6:<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</pre></blockquote>\r\n\r\nFor\s64-bit\s<tt>long</tt>:\r\n\r\n<blockquote><pre>\r\n%\sproc\se6509\s{}\s{return\s[expr\s{0x7fffffffffffffff+1}]}\r\n%\se6509\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:6509:16:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s9223372036854775807\s+\s1\scannot\sbe\srepresented\sin\stype\s'long'</span>\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:9149:16:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s9223372036854775807\s+\s1\scannot\sbe\srepresented\sin\stype\s'long'</span>\r\n9223372036854775808\r\n%\sproc\se6524\s{}\s{return\s[expr\s{-0x7fffffffffffffff-2}]}\r\n%\se6524\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:6524:16:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s-9223372036854775807\s-\s2\scannot\sbe\srepresented\sin\stype\s'long'</span>\r\n<span\sstyle="font-weight:bold">tcl/generic/tclExecute.c:9165:16:<span\sstyle="color:red">\sruntime\serror:\s</span>signed\sinteger\soverflow:\s-9223372036854775807\s-\s2\scannot\sbe\srepresented\sin\stype\s'long'</span>\r\n-9223372036854775809\r\n</pre></blockquote>\r\n\r\n(There\sis\smore\ssigned\sinteger\soverflow\sin\stclExecute.c\swhich\sI\shave\syet\sto\sreport/suggest\sfixes\sfor.)
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 48.\sNumber\sHandling
J title signed\sinteger\soverflow\sin\stclExecute.c
J type Patch
K 7f8a3d981843fe53d6a6a6bd659f3a3440bd15e3
U chrstphrchvz
Z b83547becafd4bbf24270cf0313f6803