util: Don't allow Base32/64-decoding or ParseMoney(…) on strings with embedded NUL characters. Add tests. #17753

pull practicalswift wants to merge 4 commits into bitcoin:master from practicalswift:valid-as-c-string changing 5 files +43 −0
  1. practicalswift commented at 9:28 AM on December 16, 2019: contributor

    Don't allow Base32/64-decoding or ParseMoney(…) on strings with embedded NUL characters. Add tests.

    Added tests before:

    $ src/test/test_bitcoin
    Running 385 test cases...
    test/base32_tests.cpp(31): error: in "base32_tests/base32_testvectors":
        check failure == true has failed [false != true]
    test/base64_tests.cpp(31): error: in "base64_tests/base64_testvectors":
        check failure == true has failed [false != true]
    test/util_tests.cpp(1074): error: in "util_tests/util_ParseMoney":
        check !ParseMoney(std::string("\0-1", 3), ret) has failed
    test/util_tests.cpp(1076): error: in "util_tests/util_ParseMoney":
        check !ParseMoney(std::string("1\0", 2), ret) has failed
    
    *** 4 failures are detected in the test module "Bitcoin Core Test Suite"
    

    Added tests after:

    $ src/test/test_bitcoin
    Running 385 test cases...
    
    *** No errors detected
    
  2. util: Don't allow ParseMoney(...) of strings with embedded NUL characters ccc53e43c5
  3. util: Don't allow DecodeBase64(...) of strings with embedded NUL characters 93cc18b0f6
  4. util: Don't allow DecodeBase32(...) of strings with embedded NUL characters a6fc26da55
  5. tests: Add tests for decoding/parsing of base32, base64 and money strings containing NUL characters 137c80d579
  6. DrahtBot added the label Tests on Dec 16, 2019
  7. DrahtBot added the label Utils/log/libs on Dec 16, 2019
  8. laanwj commented at 11:57 AM on December 16, 2019: member

    Code review ACK 137c80d579502e329964d7d1028a9507d4667774

  9. MarcoFalke referenced this in commit 6b51cce65a on Dec 16, 2019
  10. MarcoFalke merged this on Dec 16, 2019
  11. MarcoFalke closed this on Dec 16, 2019

  12. MarkLTZ referenced this in commit 3ec6a5c547 on Apr 9, 2020
  13. jasonbcox referenced this in commit 378e5385a5 on Oct 28, 2020
  14. practicalswift deleted the branch on Apr 10, 2021
  15. PastaPastaPasta referenced this in commit 67f1de4312 on Sep 17, 2021
  16. thelazier referenced this in commit 7fcad3c77d on Sep 25, 2021
  17. 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