Skip to content
Tcl Source Code Artifact [989d74d3c0]
Login

Artifact [989d74d3c0]

Artifact 989d74d3c038e84e82cdea2bfd8f470e77fd170e13dc15db69058030b4c689ff:

Ticket change [989d74d3c0] - Ticket [00655c867eabd57a|00655c867e] <i>ClockGetdatefieldsObjCmd(): avoid signed integer overflow and platform-dependent behavior</i> status still Pending with 4 other changes by chrstphrchvz on 2023-09-20 22:02:46.
D 2023-09-20T22:02:46.331
J comment clock-61.3\striggers\san\s<tt>-fsanitize=signed-integer-overflow</tt>\serror:\r\n<pre>\r\ngeneric/tclClock.c:472:52:\sruntime\serror:\ssigned\sinteger\soverflow:\s9223372036854775807\s+\s210866803200\scannot\sbe\srepresented\sin\stype\s'long\slong'\r\n</pre>\r\n\r\nSee\sattached\spatch.\sTo\savoid\sthe\soverflow,\sI\ssuggest\sdividing\sby\s<tt>SECONDS_PER_DAY</tt>\sfirst\sand\sthen\sadding\s<tt>JULIAN_DAY_POSIX_EPOCH</tt>\sinstead.\sThe\squotient\salso\sneeds\sto\sbe\sconsistently\srounded\sdown,\srather\struncated\stowards\s0\s(GNU\sC\sand\sC99)\sor\showever\sa\sparticular\splatform\schooses\s(C89);\sotherwise\sincorrect\sresults\sare\sproduced\sfor\stime\svalues\sprior\sto\sthe\sPOSIX\sepoch.\sNot\srounding\sdown\salready\sproduces\sincorrect\sresults\sfor\stime\svalues\sprior\sto\sJulian\sday\s0;\sthe\sproposed\sclock-7.10\stest\scurrently\sfails\swith\s\r\n<pre><span\sstyle="color:firebrick">-210866803200</span>\s-210866889600\s-1\s-210866803201\s<span\sstyle="color:firebrick">0</span>\s-210866803200\s0\s<span\sstyle="color:firebrick">0</span>\s<span\sstyle="color:firebrick">0</span></pre>\r\n\swhen\sinteger\sdivision\struncates\stoward\s0.
J icomment I\sneglected\show\s<tt>clock\sadd\s…\sdays</tt>\stakes\s<tt>-timezone</tt>\sinto\sconsideration.\sSpecifying\s<tt>-timezone\s:UTC</tt>\sto\s<tt>clock\sadd\s…\sdays</tt>\savoids\sthe\sfailure\son\s<tt>OPTS=static,msvcrt</tt>,\salthough\swhether\s<tt>GetSystemTimeZone</tt>\sis\scorrect\sor\sunexpectedly\s<tt>:localtime</tt>\sis\sbeyond\sthe\sscope\sof\sthis\stest.\s<tt>-timezone</tt>\sshould\slikely\salso\sbe\sspecified\sin\sthe\stest’s\sother\s<tt>clock\sadd</tt>\susage\sfor\sconsistency.\sSee\sattached\spatch.
J login chrstphrchvz
J mimetype text/x-fossil-wiki
K 00655c867eabd57ac3acd93bffe2f93799c12c89
U chrstphrchvz
Z 23c9009e0b5fbd6cbf11c7a1ac98aa6c