Artifacts Associated With Ticket c6fea6ba6
Ticket change [6fec51f58c] (rid 198148) by chrstphrchvz on 2022-02-16 02:15:18:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
If <tt>Tcl_GetLongFromObj()</tt> or <tt>Tcl_GetWideIntFromObj()</tt> retrieve from a bignum whose value is <tt>LONG_MIN</tt> or <tt>WIDE_MIN</tt> respectively, then I believe there will be signed integer overflow (undefined behavior) on 2's complement systems. The attached patch should avoid this by using the same approach suggested for [89de498973]: negate before casting, and by subtracting from 0 (binary minus) to avoid compiler warnings for unary minus with unsigned operand (e.g. [https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146|MSVC <tt>/W2</tt> warning C4146]). However I have not identified a Tcl syntax example to trigger the overflow, as I have not found how to create a bignum with a value representable by <tt>long</tt> or <tt>Tcl_WideInt</tt> that can be saved and used by a command that then passes it to Tcl_GetLongFromObj() or Tcl_GetWideIntFromObj(); maybe I can come up with a C example.
- foundin initialized to: "core-8-6-branch"
- is_private initialized to: "0"
- login: "chrstphrchvz"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "chrstphrchvz"
- subsystem initialized to: "48. Number Handling"
- title initialized to:
possible signed integer overflow in Tcl_GetLongFromObj(), Tcl_GetWideIntFromObj()
- type initialized to: "Patch"
Add attachment "bignum-to-long-wide.diff" [28c551a57b] (rid 198149) by chrstphrchvz on 2022-02-16 02:16:58.
Ticket change [3969100760] (rid 198175) by jan.nijtmans on 2022-02-16 15:42:55:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2459627.15481135"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed[efbf66da7d0a9b8d|here] Thanks for the report!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"