Skip to content
Tcl Source Code History Of Ticket c6fea6ba6f6b2841
Login

History Of Ticket c6fea6ba6f6b2841

Artifacts Associated With Ticket c6fea6ba6f6b2841

  1. Ticket change [6fec51f58c] (rid 198148) by chrstphrchvz on 2022-02-16 02:15:18:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. 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.
      
    5. foundin initialized to: "core-8-6-branch"
    6. is_private initialized to: "0"
    7. login: "chrstphrchvz"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "chrstphrchvz"
    13. subsystem initialized to: "48. Number Handling"
    14. title initialized to:
      possible signed integer overflow in Tcl_GetLongFromObj(), Tcl_GetWideIntFromObj()
      
    15. type initialized to: "Patch"
  2. Add attachment "bignum-to-long-wide.diff" [28c551a57b] (rid 198149) by chrstphrchvz on 2022-02-16 02:16:58.

  3. Ticket change [3969100760] (rid 198175) by jan.nijtmans on 2022-02-16 15:42:55:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2459627.15481135"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Fixed[efbf66da7d0a9b8d|here]
      
      Thanks for the report!
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"