tests: Add basic fuzzing harness for CNetAddr/CService/CSubNet related functions (netaddress.h) #18047

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:fuzzers-netaddress changing 3 files +145 −6
  1. practicalswift commented at 12:18 AM on February 1, 2020: contributor

    Add basic fuzzing harness for CNetAddr/CService/CSubNet related functions (netaddress.h).

    To test this PR:

    $ make distclean
    $ ./autogen.sh
    $ CC=clang CXX=clang++ ./configure --enable-fuzz \
          --with-sanitizers=address,fuzzer,undefined
    $ make
    $ src/test/fuzz/netaddress
    …
    
  2. fanquake added the label Tests on Feb 1, 2020
  3. in src/test/fuzz/netaddress.cpp:58 in bb1283edf5 outdated
      53 | +    (void)net_addr.IsBindAny();
      54 | +    (void)net_addr.IsLocal();
      55 | +    (void)net_addr.IsRFC2544();
      56 | +    (void)net_addr.IsRFC3927();
      57 | +    (void)net_addr.IsRFC3964();
      58 | +    (void)net_addr.IsRFC4380();
    


    jonatack commented at 6:45 AM on February 2, 2020:

    perhaps?

         (void)net_addr.IsLocal();
    +    (void)net_addr.IsRFC1918();
         (void)net_addr.IsRFC2544();
    +    (void)net_addr.IsRFC3849();
         (void)net_addr.IsRFC3927();
         (void)net_addr.IsRFC3964();
    +    (void)net_addr.IsRFC4193();
         (void)net_addr.IsRFC4380();
    

    jonatack commented at 6:54 AM on February 2, 2020:

    Testing with this edit

    [#7675466](/bitcoin-bitcoin/7675466/) REDUCE cov: 1800 ft: 3679 corp: 166/2677b exec/s: 11936 rss: 475Mb L: 31/72 MS: 2 InsertByte-EraseBytes-
    [#7718640](/bitcoin-bitcoin/7718640/) REDUCE cov: 1800 ft: 3679 corp: 166/2675b exec/s: 11948 rss: 475Mb L: 29/72 MS: 4 CopyPart-PersAutoDict-ChangeBit-EraseBytes- DE: "\xff\xff\xff\x05"-
    [#7749616](/bitcoin-bitcoin/7749616/) REDUCE cov: 1800 ft: 3679 corp: 166/2674b exec/s: 11940 rss: 475Mb L: 28/72 MS: 1 EraseBytes-
    [#8388608](/bitcoin-bitcoin/8388608/) pulse  cov: 1800 ft: 3679 corp: 166/2674b exec/s: 11983 rss: 476Mb
    

    practicalswift commented at 11:18 AM on February 13, 2020:

    IsRFC1918 etc are tested later in the file :) But I've now re-arranged so that this is more clear. Please re-review :)

  4. jonatack commented at 6:51 AM on February 2, 2020: member

    Concept/approach ACK. Runs about 10 times faster (11.5-12k exec/s) than the asmap fuzzer for me. Why is 8bb9945 described as "temporarily" and a separate commit? (I have the same question regarding the asmap fuzzer PR as well -- thanks.)

  5. practicalswift force-pushed on Feb 13, 2020
  6. practicalswift force-pushed on Mar 5, 2020
  7. practicalswift commented at 9:23 PM on March 5, 2020: contributor

    @jonatack The reason for the temporary commit was to allow for easy removal in the case that tests cases was added to the qa-assets repo before the merge of this PR :) But to make things less confusing I've now squashed the two commits into one. Please re-review :)

  8. tests: Add basic fuzzing harness for CNetAddr/CService/CSubNet related functions (netaddress.h) 815c7a6793
  9. practicalswift force-pushed on Mar 9, 2020
  10. practicalswift commented at 3:18 PM on March 9, 2020: contributor

    Rebased! :)

  11. in test/fuzz/test_runner.py:16 in 815c7a6793 outdated
      13 | @@ -14,6 +14,7 @@
      14 |  
      15 |  # Fuzzers known to lack a seed corpus in https://github.com/bitcoin-core/qa-assets/tree/master/fuzz_seed_corpus
      16 |  FUZZERS_MISSING_CORPORA = [
    


    MarcoFalke commented at 4:27 PM on March 9, 2020:

    on a second thought, this is a bit too strict and causes many merge conflicts. I think we can remove FUZZERS_MISSING_CORPORA and create the dir unconditionally. With a comment it should be fine. I believe this was your initial suggestion on how to handle the two repos going out of sync.


    practicalswift commented at 5:21 PM on March 9, 2020:

    FUZZERS_MISSING_CORPORA now removed. Now informing the user about missing seed corpora with a call to action :)

  12. in src/test/fuzz/netaddress.cpp:20 in 815c7a6793 outdated
      15 | +CNetAddr ConsumeNetAddr(FuzzedDataProvider& fuzzed_data_provider) noexcept
      16 | +{
      17 | +    const Network network = fuzzed_data_provider.PickValueInArray({Network::NET_IPV4, Network::NET_IPV6, Network::NET_INTERNAL, Network::NET_ONION});
      18 | +    if (network == Network::NET_IPV4) {
      19 | +        const in_addr v4_addr = {
      20 | +            .s_addr = fuzzed_data_provider.ConsumeIntegral<uint32_t>()};
    


    dongcarl commented at 5:09 PM on March 9, 2020:

    Feel free to ignore nit: the brace here was a little confusing to me


    practicalswift commented at 5:23 PM on March 9, 2020:

    I'm just a blind follower of clang-format -i src/test/fuzz/netaddress.cpp, so I'm afraid this is something you'll have to take directly with src/.clang-format :)

  13. dongcarl commented at 5:09 PM on March 9, 2020: member

    Code review ACK 815c7a679316e34b2072a45949ad4ecb1ae1c7fb

  14. tests: Remove FUZZERS_MISSING_CORPORA 6590395f60
  15. MarcoFalke merged this on Mar 9, 2020
  16. MarcoFalke closed this on Mar 9, 2020

  17. sidhujag referenced this in commit 0816c071a3 on Mar 10, 2020
  18. deadalnix referenced this in commit 8e86e9d426 on Nov 5, 2020
  19. sidhujag referenced this in commit c86c89164b on Nov 10, 2020
  20. practicalswift deleted the branch on Apr 10, 2021
  21. kittywhiskers referenced this in commit 4416d0a029 on May 7, 2022
  22. kittywhiskers referenced this in commit a9e4d40e21 on May 7, 2022
  23. kittywhiskers referenced this in commit b9ef56dbfd on Jun 14, 2022
  24. kittywhiskers referenced this in commit a2b48940bb on Jun 14, 2022
  25. kittywhiskers referenced this in commit 221efabce2 on Jun 14, 2022
  26. kittywhiskers referenced this in commit 9c2ab3dbd5 on Jun 18, 2022
  27. kittywhiskers referenced this in commit a6ec86aa87 on Jun 18, 2022
  28. kittywhiskers referenced this in commit f6f20da9b2 on Jul 4, 2022
  29. kittywhiskers referenced this in commit 0a77010f30 on Jul 4, 2022
  30. kittywhiskers referenced this in commit e51dd7b33d on Jul 6, 2022
  31. kittywhiskers referenced this in commit 41a68e999c on Jul 6, 2022
  32. kittywhiskers referenced this in commit 0c0947e940 on Jul 6, 2022
  33. kittywhiskers referenced this in commit 9dda325594 on Jul 13, 2022
  34. kittywhiskers referenced this in commit c6a28704dd on Jul 13, 2022
  35. kittywhiskers referenced this in commit 0d5a7929ac on Jul 15, 2022
  36. PastaPastaPasta referenced this in commit 30d6584cb6 on Jul 17, 2022
  37. DrahtBot locked this on Aug 18, 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-16 15:14 UTC

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