util: Don't allow Base58 decoding of non-Base58 strings. Add Base58 tests. #17721

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:less-liberal-base58-decoding changing 4 files +32 −1
  1. practicalswift commented at 11:13 AM on December 11, 2019: contributor

    Don't allow Base58 decoding of non-Base58 strings. Add Base58 tests.

    Fixes #17718.

    Added tests before the Base58 decoding patch:

    $ make check
    …
    test/base58_tests.cpp(62): error: in "base58_tests/base58_DecodeBase58": 
        check !DecodeBase58(std::string("\0invalid", 8), result) has failed
    test/base58_tests.cpp(67): error: in "base58_tests/base58_DecodeBase58": 
        check !DecodeBase58(std::string("good\0bad0IOl", 12), result) has failed
    test/base58_tests.cpp(76): error: in "base58_tests/base58_DecodeBase58": 
        check !DecodeBase58Check(std::string("3vQB7B6MrGQZaxCuFg4oh\00IOl", 26), result) has failed
    *** 3 failures are detected in the test module "Bitcoin Core Test Suite"
    …
    $ echo $?
    1
    

    Added tests before the Base58 decoding patch:

    $ make check
    …
    OK
    …
    $ echo $?
    0
    
  2. in src/util/string.h:40 in 419fada5c4 outdated
      33 | @@ -31,4 +34,9 @@ inline std::string Join(const std::vector<std::string>& list, const std::string&
      34 |      return Join(list, separator, [](const std::string& i) { return i; });
      35 |  }
      36 |  
      37 | +NODISCARD inline bool ValidAsCString(const std::string& str) noexcept
    


    laanwj commented at 11:18 AM on December 11, 2019:

    Please add doc comment


    practicalswift commented at 11:42 AM on December 11, 2019:

    Added!

  3. laanwj commented at 11:20 AM on December 11, 2019: member

    The ValidAsCString function could also be used in ParsePrechecks in util/strencodings.cpp

    Concept ACK, handling embedded \0 is a good thing

  4. DrahtBot added the label Tests on Dec 11, 2019
  5. DrahtBot added the label Utils/log/libs on Dec 11, 2019
  6. practicalswift renamed this:
    util: Don't allow Base58 decoding of non-Base58 strings. Add base58 tests.
    util: Don't allow Base58 decoding of non-Base58 strings. Add Base58 tests.
    on Dec 11, 2019
  7. practicalswift force-pushed on Dec 11, 2019
  8. practicalswift commented at 11:42 AM on December 11, 2019: contributor

    @laanwj Done! Please re-review :)

  9. DrahtBot commented at 5:29 PM on December 11, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17229 (tests: Add fuzzing harnesses for various Base{32,58,64} and hex related functions by practicalswift)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  10. DrahtBot added the label Needs rebase on Dec 12, 2019
  11. practicalswift force-pushed on Dec 12, 2019
  12. tests: Add tests for base58-decoding of std::string:s containing non-base58 characters ff7a999226
  13. util: Don't allow base58-decoding of std::string:s containing non-base58 characters d945c6f5e6
  14. practicalswift force-pushed on Dec 12, 2019
  15. DrahtBot removed the label Needs rebase on Dec 12, 2019
  16. MarcoFalke commented at 6:49 PM on December 12, 2019: member

    ACK d945c6f5e6f61b6e289ac7da6834c18f1b677b0f 🚓

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK d945c6f5e6f61b6e289ac7da6834c18f1b677b0f 🚓
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUjp8wwAt5wscJYjWfiEnu9M+49OV4+guwH6mbNoDLWnuJ16Keb0GlH9mCngbhU3
    oRs7un9SIlO9s9kAwBGao6af+FrlDg3QgJO/Y7YXs3ugcvMm6L3flMUcmqRdmaqg
    TacubBoe/D5Jcfp08sC5hP8KHyglRfHJ6tkSSkwv7EwSlZ+VvqpnvRQT5Bxz7o90
    WfaMFXTTKVZwkAb8eYnBX6A4FfIemvv31VbDk993oOZ4qPgtaXw4ow5j3fMhlvQS
    65ENCksGXNQartyUDn2NJE8kZelsvnaD5LP18cnfRj3iTXX0VMQjNU0aWXIUER2E
    2qY0AbhtM6zN/ujECUUJvJfvcYRn3R+ODpJ1197s9nkZnhiCTU0/WLKSmU04Uhku
    NYFKVvVyBZR2MbNdv7zhM5LfRFiX+QovY2bdgJvj/WNL8x+PFPX5j5UZi1j+U0tu
    vyMfOohkT8xquAyLLkEyMWvcbcDMdWi1LCvLYWskHJ2vVdfdvc/fAK8VwTh+75AJ
    UwkOh6KI
    =XLYr
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 715c326e53e59aa78e26d17ed651e7efc2a70b43763dca45dca48f34fa22d05a -

    </details>

  17. laanwj commented at 10:15 AM on December 13, 2019: member

    ACK d945c6f5e6f61b6e289ac7da6834c18f1b677b0f

  18. laanwj referenced this in commit 995b6c83e1 on Dec 13, 2019
  19. laanwj merged this on Dec 13, 2019
  20. laanwj closed this on Dec 13, 2019

  21. sidhujag referenced this in commit db2f0b32fa on Dec 13, 2019
  22. jasonbcox referenced this in commit bd611af6fa on Oct 28, 2020
  23. sidhujag referenced this in commit b4bf670575 on Nov 10, 2020
  24. practicalswift deleted the branch on Apr 10, 2021
  25. kittywhiskers referenced this in commit c8e14a3e41 on May 25, 2021
  26. UdjinM6 referenced this in commit 50f95ca817 on May 28, 2021
  27. furszy referenced this in commit 170beab56c on Jul 1, 2021
  28. random-zebra referenced this in commit b4751e10ce on Aug 11, 2021
  29. gades referenced this in commit 38cae596eb on Apr 26, 2022
  30. DrahtBot locked this on Aug 16, 2022

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:14 UTC

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