Remove possibility of 63 bit overflow in ParseMoney #543

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:utiltests changing 4 files +275 −8
  1. laanwj commented at 1:06 AM on October 1, 2011: member

    ParseMoney checks for a maximum number of digits before the dot, returning invalid if that is exceeded, supposedly guarding against overflow. However, this amount is set far too lenient (14) making it possible to overflow from positive into negative integer values:

    10   9999999999.99999999   -> 9999999999999999999
    11   99999999999.99999999 -> -8446744073709551617
    ... 
    

    This commit sets the maximum number of digits before the dot to 10, the maximum safe value. It also adds unit tests for various functions in util.cpp/util.h and base58.

  2. remove possibility of 63 bit overflow in ParseMoney
    - also, add unit tests for various functions in util.cpp/util.h
    2f7f2a5fca
  3. gavinandresen commented at 5:00 PM on October 1, 2011: contributor

    ACK

  4. gavinandresen referenced this in commit 1ff3583e41 on Oct 1, 2011
  5. gavinandresen merged this on Oct 1, 2011
  6. gavinandresen closed this on Oct 1, 2011

  7. gavinandresen commented at 5:21 PM on October 2, 2011: contributor

    Error compiling on my mac: test/util_tests.cpp:120: error: integer constant is too large for ‘long’ type make: *** [obj/test/test_bitcoin.o] Error 1

  8. laanwj commented at 5:46 PM on October 2, 2011: member

    Right, the type specifier is missing. Seems that for your gcc it's changed from a warning to an error. Line 120 should be

    BOOST_CHECK_EQUAL(GetArg("inttest2", -1), 81985529216486895LL);
    

    Some day we should start compiling with warnings enabled...

  9. coblee referenced this in commit 5d557fc47d on Jul 17, 2012
  10. KolbyML referenced this in commit bc86927231 on Sep 4, 2020
  11. KolbyML referenced this in commit 48e3c91e8c on Dec 5, 2020
  12. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me